| Crates.io | slice-cast |
| lib.rs | slice-cast |
| version | 0.1.2 |
| created_at | 2016-12-05 07:05:35.689336+00 |
| updated_at | 2016-12-08 01:02:04.247985+00 |
| description | Support for casting between slice types |
| homepage | |
| repository | https://github.com/FaultyRAM/slice-cast |
| max_upload_size | |
| id | 7474 |
| size | 22,893 |
This Rust library provides support for performing cast operations on slices.
The cast() and cast_mut() functions perform casts between slice types:
extern crate slice_cast;
fn main() {
let foo: [u8; 4] = [1, 0, 0, 0];
let bar: &[u32] = unsafe { slice_cast::cast(&foo) };
println!("{:?}", bar);
}
The cast_to() and cast_to_mut() functions perform casts from slices into
concrete types:
extern crate slice_cast;
fn main() {
let foo: [u8; 4] = [1, 0, 0, 0];
let bar: &u32 = unsafe { slice_cast::cast_to(&foo) };
println!("{}", bar);
}
Add the following line to your [dependencies] in Cargo.toml:
slice-cast = "0.1"
And add the following line to your crate root:
extern crate slice_cast;
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.