Created
September 10, 2017 03:41
-
-
Save anonymous/e6920c2e329279461ab9e22aa3eaf187 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::boxed::Box; | |
fn a(value: usize) -> Box<[usize]> { | |
vec![0; value].into_boxed_slice() | |
} | |
fn main() { | |
let val = a(5); | |
let test = Test { | |
arr: val, | |
}; | |
println!("{:?}", test); | |
let val = a(10); | |
let test = Test { | |
arr: val, | |
}; | |
println!("{:?}", test); | |
} | |
#[derive(Debug)] | |
struct Test { | |
arr: Box<[usize]>, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.reddit.com/r/rust/comments/3gp0tl/dynamic_fixed_sized_arrays/