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);
242
242
243
243
impl Term {
244
244
pub fn intern ( string : & str ) -> Term {
245
- Term ( string . into ( ) )
245
+ Term ( imp :: Term :: intern ( string ) )
246
246
}
247
247
248
248
pub fn as_str ( & self ) -> & str {
249
- & self . 0
249
+ self . 0 . as_str ( )
250
250
}
251
251
}
252
252
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ use std::collections::HashMap;
7
7
use std:: fmt;
8
8
use std:: iter;
9
9
use std:: marker:: PhantomData ;
10
- use std:: ops;
11
10
use std:: rc:: Rc ;
12
11
use std:: str:: FromStr ;
13
12
use std:: vec;
@@ -398,19 +397,15 @@ pub struct Term {
398
397
399
398
thread_local ! ( static SYMBOLS : RefCell <Interner > = RefCell :: new( Interner :: new( ) ) ) ;
400
399
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 {
403
402
Term {
404
403
intern : SYMBOLS . with ( |s| s. borrow_mut ( ) . intern ( string) ) ,
405
404
not_send_sync : PhantomData ,
406
405
}
407
406
}
408
- }
409
-
410
- impl ops:: Deref for Term {
411
- type Target = str ;
412
407
413
- fn deref ( & self ) -> & str {
408
+ pub fn as_str ( & self ) -> & str {
414
409
SYMBOLS . with ( |interner| {
415
410
let interner = interner. borrow ( ) ;
416
411
let s = interner. get ( self . intern ) ;
@@ -423,7 +418,7 @@ impl ops::Deref for Term {
423
418
424
419
impl fmt:: Debug for Term {
425
420
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 ( )
427
422
}
428
423
}
429
424
Original file line number Diff line number Diff line change 1
1
use std:: ascii;
2
2
use std:: fmt;
3
3
use std:: iter;
4
- use std:: ops;
5
4
use std:: str:: FromStr ;
6
5
7
6
use proc_macro;
@@ -269,16 +268,12 @@ impl fmt::Debug for Span {
269
268
#[ derive( Copy , Clone ) ]
270
269
pub struct Term ( proc_macro:: Term ) ;
271
270
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 {
274
273
Term ( proc_macro:: Term :: intern ( string) )
275
274
}
276
- }
277
-
278
- impl ops:: Deref for Term {
279
- type Target = str ;
280
275
281
- fn deref ( & self ) -> & str {
276
+ pub fn as_str ( & self ) -> & str {
282
277
self . 0 . as_str ( )
283
278
}
284
279
}
You can’t perform that action at this time.
0 commit comments