File tree 1 file changed +20
-3
lines changed
1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,13 @@ use std::collections::HashSet;
4
4
use std:: slice;
5
5
use std:: str;
6
6
use std:: mem;
7
+ use std:: cmp:: Ordering ;
7
8
8
9
pub fn leek ( s : String ) -> & ' static str {
9
- let ptr = s. as_ptr ( ) ;
10
- let len = s. len ( ) ;
11
- mem:: forget ( s) ;
10
+ let boxed = s. into_boxed_str ( ) ;
11
+ let ptr = boxed. as_ptr ( ) ;
12
+ let len = boxed. len ( ) ;
13
+ mem:: forget ( boxed) ;
12
14
unsafe {
13
15
let slice = slice:: from_raw_parts ( ptr, len) ;
14
16
str:: from_utf8_unchecked ( slice)
@@ -49,3 +51,18 @@ impl fmt::Debug for InternedString {
49
51
write ! ( f, "InternedString {{ {} }}" , self . to_inner( ) )
50
52
}
51
53
}
54
+
55
+ impl Ord for InternedString {
56
+ fn cmp ( & self , other : & InternedString ) -> Ordering {
57
+ self . to_inner ( ) . cmp ( & other. to_inner ( ) )
58
+ }
59
+ }
60
+
61
+ impl PartialOrd for InternedString {
62
+ fn partial_cmp ( & self , other : & InternedString ) -> Option < Ordering > {
63
+ Some ( self . cmp ( other) )
64
+ }
65
+ }
66
+
67
+ unsafe impl Send for InternedString { }
68
+ unsafe impl Sync for InternedString { }
You can’t perform that action at this time.
0 commit comments