File tree Expand file tree Collapse file tree 3 files changed +9
-19
lines changed Expand file tree Collapse file tree 3 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -242,11 +242,11 @@ pub struct Term(imp::Term);
242242
243243impl Term {
244244 pub fn intern ( string : & str ) -> Term {
245- Term ( string . into ( ) )
245+ Term ( imp :: Term :: intern ( string ) )
246246 }
247247
248248 pub fn as_str ( & self ) -> & str {
249- & self . 0
249+ self . 0 . as_str ( )
250250 }
251251}
252252
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ use std::collections::HashMap;
77use std:: fmt;
88use std:: iter;
99use std:: marker:: PhantomData ;
10- use std:: ops;
1110use std:: rc:: Rc ;
1211use std:: str:: FromStr ;
1312use std:: vec;
@@ -398,19 +397,15 @@ pub struct Term {
398397
399398thread_local ! ( static SYMBOLS : RefCell <Interner > = RefCell :: new( Interner :: new( ) ) ) ;
400399
401- impl < ' a > From < & ' a str > for Term {
402- fn from ( string : & ' a str ) -> Term {
400+ impl Term {
401+ pub fn intern ( string : & str ) -> Term {
403402 Term {
404403 intern : SYMBOLS . with ( |s| s. borrow_mut ( ) . intern ( string) ) ,
405404 not_send_sync : PhantomData ,
406405 }
407406 }
408- }
409-
410- impl ops:: Deref for Term {
411- type Target = str ;
412407
413- fn deref ( & self ) -> & str {
408+ pub fn as_str ( & self ) -> & str {
414409 SYMBOLS . with ( |interner| {
415410 let interner = interner. borrow ( ) ;
416411 let s = interner. get ( self . intern ) ;
@@ -423,7 +418,7 @@ impl ops::Deref for Term {
423418
424419impl fmt:: Debug for Term {
425420 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
426- f. debug_tuple ( "Term" ) . field ( & & * * self ) . finish ( )
421+ f. debug_tuple ( "Term" ) . field ( & self . as_str ( ) ) . finish ( )
427422 }
428423}
429424
Original file line number Diff line number Diff line change 11use std:: ascii;
22use std:: fmt;
33use std:: iter;
4- use std:: ops;
54use std:: str:: FromStr ;
65
76use proc_macro;
@@ -269,16 +268,12 @@ impl fmt::Debug for Span {
269268#[ derive( Copy , Clone ) ]
270269pub struct Term ( proc_macro:: Term ) ;
271270
272- impl < ' a > From < & ' a str > for Term {
273- fn from ( string : & ' a str ) -> Term {
271+ impl Term {
272+ pub fn intern ( string : & str ) -> Term {
274273 Term ( proc_macro:: Term :: intern ( string) )
275274 }
276- }
277-
278- impl ops:: Deref for Term {
279- type Target = str ;
280275
281- fn deref ( & self ) -> & str {
276+ pub fn as_str ( & self ) -> & str {
282277 self . 0 . as_str ( )
283278 }
284279}
You can’t perform that action at this time.
0 commit comments