small_fixed_array/lib.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//! A crate for [`FixedArray`] and [`FixedString`], types to provide a smaller memory footprint in exchange for:
//! - Immutablity, [`FixedArray`] and [`FixedString`] cannot be mutated without converting back to their expanded forms.
//! - Maximum length, [`FixedArray`] and [`FixedString`] have a length cap of `LenT::MAX` elements.
//!
//! These types provide cheap conversions to [`Vec`] and [`String`], to make up for most of these downsides, but it is
//! still not recommended to use these collections for mutated values as you will see a performance downside.
//!
//! These can be thought of as `Box<[T]>` and `Box<str>`, except the length is denoted as `LenT`, by default [`u32`].
//!
//! ## Features
//! - `nightly`: Speeds up [`FixedString::len`] for small strings, using `portable_simd`.
//! - `serde`: Provides [`serde`] implementations for [`FixedArray`] and [`FixedString`].
//! - `typesize`: Provides [`typesize`] implementations for [`FixedArray`] and [`FixedString`].
//!
//! ## MSRV
//! The Minimum Supported Rust Version of this crate is 1.70.
//!
//! It is considered a breaking change to raise this.
#![cfg_attr(feature = "nightly", feature(portable_simd))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "std", allow(unused_imports))]
#![warn(clippy::pedantic, clippy::as_conversions)]
#![allow(clippy::module_name_repetitions, unknown_lints)]
extern crate alloc;
mod array;
mod inline;
mod length;
mod r#static;
mod string;
mod truncating_into;
pub use array::FixedArray;
pub use length::ValidLength;
pub use string::FixedString;
pub use truncating_into::TruncatingInto;