Skip to content

Instantly share code, notes, and snippets.

Created September 10, 2017 03:41
Show Gist options
  • Save anonymous/e6920c2e329279461ab9e22aa3eaf187 to your computer and use it in GitHub Desktop.
Save anonymous/e6920c2e329279461ab9e22aa3eaf187 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
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