raw-parts
A wrapper around the decomposed parts of a Vec<T>
.
This struct contains the Vec
's internal pointer, length, and allocated
capacity.
RawParts
makes Vec::from_raw_parts
and Vec::into_raw_parts
easier to
use by giving names to the returned values. This prevents errors from mixing up
the two usize
values of length and capacity.
Usage
Add this to your Cargo.toml
:
[]
= "2.0.0"
Then decompose Vec<T>
s like:
use RawParts;
let v: = vec!;
let RawParts = from_vec;
let rebuilt = unsafe ;
assert_eq!;
no_std
raw-parts is no_std
compatible with a required dependency on alloc
.
Minimum Supported Rust Version
This crate requires at least Rust 1.56.0. This version can be bumped in minor releases.
License
raw-parts
is licensed under the MIT License (c) Ryan Lopopolo.