reinterpret
Low level utility functions to reinterpret arrays of data in Rust
Overview
This crate provides convenient low-level utility functions for reinterpreting data.
This includes Vec
s and slice
s. These functions are intrinsically unsafe but are very
useful in performance critical code since they avoid additional copies.
The goal of this crate is to provide some memory safety along the boundaries of Vec
s and
slice
s to reduce the boilerplate for reinterpreting data.
These functions check that the source and target arrays have the same size, however they don't check for safety of converting the contained types.
It is possible to write safe wrappers for converting collections of concrete types using these functions, however this is out of the scope of this crate.
Examples
# extern crate reinterpret;
# use *;
#
Undefined Behavior
There are ways to misuse these functions without causing panics that may produce undefined behavior. For instance:
# extern crate reinterpret;
# use *;
#
License
This repository is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.