| ▲ | tialaramex 3 days ago | |||||||
I think what you'd most likely do here is something like:
Edited to fix early enter oops, typo in loop length that'd be caught if I'd tried this. | ||||||||
| ▲ | phire 3 days ago | parent | next [-] | |||||||
Only problem with that approach is that assume_init() is unsafe (because it depends on you getting the initialisation loop correct), and many people are (correctly) hesitant to use unsafe. IMO, it would be really nice if the naive syntax was guaranteed to work, rather than requiring programmers to remember a new workaround syntax (new_uninit_slice() was only stabilised a year ago). This edge case is a little annoying because the naive approach will usually work for a release build, but then fail when you with back to a debug build. | ||||||||
| ||||||||
| ▲ | csmantle 3 days ago | parent | prev [-] | |||||||
This will soon gets cumbersome if we're trying to construct some large struct literals (rather than arrays) directly on heap. Rust should be able to elide the unnecessary stack allocation here. | ||||||||