@@ -70,7 +70,6 @@ define uninitialized `static mut` values.
7070
7171*/
7272
73- #![ crate_id = "lazy_static" ]
7473#![ crate_type = "dylib" ]
7574#![ license = "MIT" ]
7675
@@ -82,8 +81,8 @@ macro_rules! lazy_static {
8281 $(
8382 #[ allow( non_camel_case_types) ]
8483 #[ allow( dead_code) ]
85- struct $N { __unit__ : ( ) }
86- static $N: $N = $N { __unit__ : ( ) } ;
84+ struct $N { __private_field : ( ) }
85+ static $N: $N = $N { __private_field : ( ) } ;
8786 impl Deref <$T> for $N {
8887 fn deref<' a>( & ' a self ) -> & ' a $T {
8988 use std:: sync:: { Once , ONCE_INIT } ;
@@ -104,46 +103,6 @@ macro_rules! lazy_static {
104103 }
105104 }
106105 }
107-
108106 ) *
109107 }
110108}
111-
112- #[ cfg( test) ]
113- mod test {
114- use std:: collections:: HashMap ;
115-
116- lazy_static ! {
117- static ref NUMBER : uint = times_two( 3 ) ;
118- static ref VEC : [ Box <uint>, ..3 ] = [ box 1 , box 2 , box 3 ] ;
119- static ref OWNED_STRING : String = "hello" . to_string( ) ;
120- static ref HASHMAP : HashMap <uint, & ' static str > = {
121- let mut m = HashMap :: new( ) ;
122- m. insert( 0 u, "abc" ) ;
123- m. insert( 1 , "def" ) ;
124- m. insert( 2 , "ghi" ) ;
125- m
126- } ;
127- static ref UNUSED : ( ) = ( ) ;
128- }
129-
130- fn times_two ( n : uint ) -> uint {
131- n * 2
132- }
133-
134- #[ test]
135- fn test_basic ( ) {
136- assert_eq ! ( OWNED_STRING . as_slice( ) , "hello" ) ;
137- assert_eq ! ( * NUMBER , 6 ) ;
138- assert ! ( HASHMAP . find( & 1 ) . is_some( ) ) ;
139- assert ! ( HASHMAP . find( & 3 ) . is_none( ) ) ;
140- assert_eq ! ( VEC . as_slice( ) , & [ box 1 , box 2 , box 3 ] ) ;
141- }
142-
143- #[ test]
144- fn test_repeat ( ) {
145- assert_eq ! ( * NUMBER , 6 ) ;
146- assert_eq ! ( * NUMBER , 6 ) ;
147- assert_eq ! ( * NUMBER , 6 ) ;
148- }
149- }
0 commit comments