File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ fn tuples() {
193193
194194#[ test]
195195fn traits ( ) {
196- // a trait is like an interface, can contain virtual functions
196+ // a trait is like an interface, can contain methods
197197 trait Zero {
198198 const ZERO : Self ;
199199 fn is_zero ( & self ) -> bool ;
@@ -254,20 +254,24 @@ fn raw_pointers() {
254254
255255#[ test]
256256fn scope ( ) {
257+ //static S:String = String::from("a");
257258 let mut a = String :: from ( "a" ) ;
258259 fn delete ( _arg : String ) {
259260 // argument is moved end deleted by destructor
260261 }
262+ delete ( a. clone ( ) ) ;
263+ assert_eq ! ( a, "a" ) ;
261264 if false {
262- delete ( a) ; // the value is moved here even under the "if false"
265+ delete ( a) ; // the value is moved here even it is assert_eq!(a, "a"); under the "if false"
263266 }
264267 // value of a is undefined here
268+ //assert_eq!(a, "a"); // error: value borrowed here after move
265269 a = "1" . to_string ( ) ; // reusing a
266270 let c = a;
267- // value of a is unusable here
271+ // value of a is undefined here
268272 assert_eq ! ( c, "1" ) ;
269273 a = c;
270- // c is unusable because is immutable
274+ // c is unusable because it is immutable
271275 //c = a; // error: cannot assign twice to immutable variable
272276 assert_eq ! ( a, "1" ) ;
273277}
You can’t perform that action at this time.
0 commit comments