You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uninitialized fixed size arrays always throw Use of possibly uninitialized variable errors, even if all the indices are allocated. Is there a way around this? If not, it shouldn't be possible to create uninitialized fixed size arrays.
structNum{s:int}fnmain(){let s = box Num{s:5};letmut a:[&Num, ..5];
a[0] = &*s; a[1] = &*s; a[2] = &*s; a[3] = &*s; a[4] = &*s;println!("{}", a[0].s)// error: use of possibly uninitialized variable: `a[..].s`}
The text was updated successfully, but these errors were encountered:
prajwalkman
changed the title
Exhaustiveness checks for unintialized fixed size arrays
Exhaustiveness checks for unintialized fixed size arrays always errors out
Jul 21, 2014
prajwalkman
changed the title
Exhaustiveness checks for unintialized fixed size arrays always errors out
Exhaustiveness checks for unintialized fixed size arrays always fails
Jul 22, 2014
prajwalkman
changed the title
Exhaustiveness checks for unintialized fixed size arrays always fails
Initialization checks for fixed size arrays not initialized during declaration always fails
Jul 22, 2014
Closing as working as intended. In Rust you generally can't deal with uninitialized memory. If Num had a destructor then it would destruct invalid memory if one of the initializations initiated task failure.
For fixed size arrays you'll have to explicitly assign each element upon creation.
Uninitialized fixed size arrays always throw
Use of possibly uninitialized variable
errors, even if all the indices are allocated. Is there a way around this? If not, it shouldn't be possible to create uninitialized fixed size arrays.The text was updated successfully, but these errors were encountered: