1 unstable release
new 0.0.1 | Nov 14, 2024 |
---|
#31 in #no-heap
Used in 9 crates
(via swamp-asset-id)
6KB
78 lines
📦 FixStr
A zero-allocation, fixed-capacity string type that lives entirely on the stack.
🚀 Features
- ✨ Zero heap allocations
- 📏 Configurable fixed capacity
- 🔒 Guaranteed UTF-8 validity
- 🎯 Perfect for small strings
- 🔄 Implements common traits (
Clone
,Copy
,Debug
, etc.)
📥 Installation
Add this to your Cargo.toml
:
[dependencies]
fixstr = "0.0.1"
📜 License This project is licensed under the MIT License - see the LICENSE file for details.
lib.rs
:
A small string type with fixed capacity stored on the stack
Examples
use fixstr::FixStr;
// Create a FixStr with capacity of 16 octets
let tiny: FixStr<16> = FixStr::new("Hello").unwrap();
assert_eq!(tiny.as_str(), "Hello");
assert_eq!(tiny.capacity(), 16);
// FixStr implements common traits
let tiny2: FixStr<16> = "World".try_into().unwrap();
let message: String = tiny2.into();