These are chat archives for rust-lang/rust

11th
Sep 2016
Vincent Cantin
@green-coder
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
@green-coder
Sep 11 2016 04:57
Maybe there is something you can do with std::default::Default
Alexander Ronald Altman
@pthariensflame
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
@emoon
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 https://doc.rust-lang.org/std/mem/fn.uninitialized.html
Stepan Koltsov
@stepancheg
Sep 11 2016 21:47
Hi. This code doesn't work due to limitations of borrow checker (I believe, it is safe and correct): https://is.gd/4Tgq9K What is a work around?