Skip to content

Commit b79f9af

Browse files
committed
constants
1 parent ca4980a commit b79f9af

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

rust/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,15 @@ fn scope() {
259259
if false {
260260
delete(a); // the value is moved here even under the "if false"
261261
}
262-
// value of a is unusable here
263-
a = "1".to_string();
262+
// value of a is undefined here
263+
a = "1".to_string(); // reusing a
264264
let c = a;
265265
// value of a is unusable here
266-
assert_eq!(c, "1")
266+
assert_eq!(c, "1");
267+
a = c;
268+
// c is unusable because is unmutable
269+
//c = a; // error: cannot assign twice to immutable variable
270+
assert_eq!(a, "1");
267271
}
268272

269273
#[test]

0 commit comments

Comments
 (0)