| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
FixedSliceVec is a dynamic length Vec with runtime-determined maximum capacity backed by a slice.
This library is focused on meeting the following, narrow use case:
fixed-slice-vec is a Rust library, built and tested via Cargo. It has no dependencies outside of the Rust core library.
To add fixed-slice-vec to your Rust project, add a dependency to it in your Cargo.toml file.
fixed-slice-vec = "0.10.0"In your Rust project source code, you can create a FixedSliceVec a number of ways (see the project Rust API docs for details). The most common form of construction is from a slice of uninitialized bytes.
use fixed_slice_vec::FixedSliceVec;
use core::mem::MaybeUninit;
// Safe to construct arrays of uninitialized values.
let mut bytes: [MaybeUninit<u8>; 1024] = unsafe { MaybeUninit::uninit().assume_init() };
let byte_slice = &mut bytes[..512];
let mut vec: FixedSliceVec<f64> = FixedSliceVec::from_uninit_bytes(byte_slice);
assert_eq!(0, vec.len());
assert!(vec.capacity() >= 63, "The exact capacity will depend on source-slice alignment");
vec.try_push(2.7f64).expect("Ran out of capacity unexpectedly");
assert_eq!(1, vec.len());
vec.clear();
assert!(vec.is_empty());As a companion to FixedSliceVec, the single submodule provides functions for working with individual Rust values backed by arbitrary byte slices. See the API Docs for details and examples.
Several other Vec-like crates exist and should be considered as possible alternatives to FixedSliceVec.
Copyright 2020 Auxon Corporation, released under the Apache 2.0 license.
| Back | FazBrowse Home | New Git URL |