These are chat archives for rust-lang/rust

Sep 2016
Vincent Cantin
Sep 11 2016 04:46
I think that you just need to allocate your structure (with default values on it), then when you are ready to initialize it, call your own-made initialization function on it.
For arrays, I think you can allocate using something like (not tested + I am a beginner) let a: [MyStruct; 42] = [myDefaultStructValue; 42];
Vincent Cantin
Sep 11 2016 04:57
Maybe there is something you can do with std::default::Default
Alexander Ronald Altman
Sep 11 2016 17:21
What about using std::mem::zeroed? As long as you can guarantee that it's overwritten in every slot before use.
Daniel Collin
Sep 11 2016 17:42
Unless this code is performance critical I would keep the default init. If you really need it not to be you can use this
Stepan Koltsov
Sep 11 2016 21:47
Hi. This code doesn't work due to limitations of borrow checker (I believe, it is safe and correct): What is a work around?