How to set a Rust array length dynamically?

前端 未结 3 1663
面向向阳花
面向向阳花 2020-12-06 09:13

I want to create array like this:

let arr = [0; length];

Where length is a usize. But I get this error



        
3条回答
  •  北海茫月
    2020-12-06 09:57

    This would be possible after variable length arrays (VLA) are implemented.

    https://doc.rust-lang.org/beta/unstable-book/language-features/unsized-locals.html

提交回复
热议问题