init_with
Have you wanted to be able to initialize a fixed array in Rust by calling a function to create each element? Now you can!
use InitWith;
let my_array = ;
assert_eq!;
Alternatively, init_with_indices
can be used to more easily create array entries based on their index:
use InitWith;
let squares = init_with_indices;
assert_eq!;
This crate lets you initialize the array elements in a functional manner while hiding the unsafe code that's needed to do so.
To import this crate, put the following into your Cargo.toml:
[]
= "1.1.0"
...and the following in your crate root:
extern crate init_with;