File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
src/bootstrap/src/utils/cache Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
use std:: path:: PathBuf ;
2
2
3
- use crate :: utils:: cache:: { INTERNER , Internable , TyIntern } ;
3
+ use crate :: utils:: cache:: { INTERNER , Internable , Interner , TyIntern } ;
4
4
5
5
#[ test]
6
6
fn test_string_interning ( ) {
7
- let s1 = INTERNER . intern_str ( "Hello" ) ;
8
- let s2 = INTERNER . intern_str ( "Hello" ) ;
9
- let s3 = INTERNER . intern_str ( "world" ) ;
7
+ let interner = Interner :: default ( ) ;
8
+ let s1 = interner. intern_str ( "Hello" ) ;
9
+ let s2 = interner. intern_str ( "Hello" ) ;
10
+ let s3 = interner. intern_str ( "world" ) ;
10
11
11
12
assert_eq ! ( s1, s2, "Same strings should be interned to the same instance" ) ;
12
13
assert_ne ! ( s1, s3, "Different strings should have different interned values" ) ;
13
14
}
14
15
15
16
#[ test]
16
17
fn test_interned_equality ( ) {
18
+ // Because we compare with &str, and the Deref impl accesses the global
19
+ // INTERNER variable, we cannot use a local Interner variable here.
17
20
let s1 = INTERNER . intern_str ( "test" ) ;
18
21
let s2 = INTERNER . intern_str ( "test" ) ;
19
22
You can’t perform that action at this time.
0 commit comments