@@ -806,9 +806,9 @@ impl Ident {
806
806
Ident :: new ( self . name , self . span . modern_and_legacy ( ) )
807
807
}
808
808
809
- /// Convert the name to a `LocalInternedString `. This is a slowish
810
- /// operation because it requires locking the symbol interner.
811
- pub fn as_str ( self ) -> LocalInternedString {
809
+ /// Convert the name to a `SymbolStr `. This is a slowish operation because
810
+ /// it requires locking the symbol interner.
811
+ pub fn as_str ( self ) -> SymbolStr {
812
812
self . name . as_str ( )
813
813
}
814
814
}
@@ -896,11 +896,11 @@ impl Symbol {
896
896
} )
897
897
}
898
898
899
- /// Convert to a `LocalInternedString `. This is a slowish operation because
900
- /// it requires locking the symbol interner.
901
- pub fn as_str ( self ) -> LocalInternedString {
899
+ /// Convert to a `SymbolStr `. This is a slowish operation because it
900
+ /// requires locking the symbol interner.
901
+ pub fn as_str ( self ) -> SymbolStr {
902
902
with_interner ( |interner| unsafe {
903
- LocalInternedString {
903
+ SymbolStr {
904
904
string : std:: mem:: transmute :: < & str , & str > ( interner. get ( self ) )
905
905
}
906
906
} )
@@ -973,6 +973,7 @@ impl Interner {
973
973
self . names . insert ( string, name) ;
974
974
name
975
975
}
976
+
976
977
// Get the symbol as a string. `Symbol::as_str()` should be used in
977
978
// preference to this function.
978
979
pub fn get ( & self , symbol : Symbol ) -> & str {
@@ -1092,15 +1093,14 @@ fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
1092
1093
/// safely treat `string` which points to interner data, as an immortal string,
1093
1094
/// as long as this type never crosses between threads.
1094
1095
//
1095
- // FIXME: ensure that the interner outlives any thread which uses
1096
- // `LocalInternedString`, by creating a new thread right after constructing the
1097
- // interner.
1096
+ // FIXME: ensure that the interner outlives any thread which uses `SymbolStr`,
1097
+ // by creating a new thread right after constructing the interner.
1098
1098
#[ derive( Clone , Eq , PartialOrd , Ord ) ]
1099
- pub struct LocalInternedString {
1099
+ pub struct SymbolStr {
1100
1100
string : & ' static str ,
1101
1101
}
1102
1102
1103
- impl < U : ?Sized > std:: convert:: AsRef < U > for LocalInternedString
1103
+ impl < U : ?Sized > std:: convert:: AsRef < U > for SymbolStr
1104
1104
where
1105
1105
str : std:: convert:: AsRef < U >
1106
1106
{
@@ -1110,28 +1110,28 @@ where
1110
1110
}
1111
1111
}
1112
1112
1113
- impl < T : std:: ops:: Deref < Target = str > > std:: cmp:: PartialEq < T > for LocalInternedString {
1113
+ impl < T : std:: ops:: Deref < Target = str > > std:: cmp:: PartialEq < T > for SymbolStr {
1114
1114
fn eq ( & self , other : & T ) -> bool {
1115
1115
self . string == other. deref ( )
1116
1116
}
1117
1117
}
1118
1118
1119
- impl !Send for LocalInternedString { }
1120
- impl !Sync for LocalInternedString { }
1119
+ impl !Send for SymbolStr { }
1120
+ impl !Sync for SymbolStr { }
1121
1121
1122
- impl std:: ops:: Deref for LocalInternedString {
1122
+ impl std:: ops:: Deref for SymbolStr {
1123
1123
type Target = str ;
1124
1124
#[ inline]
1125
1125
fn deref ( & self ) -> & str { self . string }
1126
1126
}
1127
1127
1128
- impl fmt:: Debug for LocalInternedString {
1128
+ impl fmt:: Debug for SymbolStr {
1129
1129
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1130
1130
fmt:: Debug :: fmt ( self . string , f)
1131
1131
}
1132
1132
}
1133
1133
1134
- impl fmt:: Display for LocalInternedString {
1134
+ impl fmt:: Display for SymbolStr {
1135
1135
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1136
1136
fmt:: Display :: fmt ( self . string , f)
1137
1137
}
0 commit comments