# slice-cast [![Build Status](https://travis-ci.org/FaultyRAM/slice-cast.svg?branch=master)](https://travis-ci.org/FaultyRAM/slice-cast) [![crates.io](https://img.shields.io/crates/v/slice-cast.svg)](https://crates.io/crates/slice-cast) [![docs.rs](https://docs.rs/slice-cast/badge.svg)](https://docs.rs/slice-cast/) This [Rust](https://www.rust-lang.org) library provides support for performing cast operations on slices. The `cast()` and `cast_mut()` functions perform casts between slice types: ```rust 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: ```rust 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); } ``` ## Usage Add the following line to your `[dependencies]` in `Cargo.toml`: ```toml slice-cast = "0.1" ``` And add the following line to your crate root: ```rust extern crate slice_cast; ``` ## License Licensed under either of * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. ### Contribution 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.