https://github.com/alcalzone/tinyvec
A fixed-capacity vector type for Rust with just a single byte of overhead
https://github.com/alcalzone/tinyvec
Last synced: 10 months ago
JSON representation
A fixed-capacity vector type for Rust with just a single byte of overhead
- Host: GitHub
- URL: https://github.com/alcalzone/tinyvec
- Owner: AlCalzone
- License: mit
- Created: 2025-03-21T20:21:45.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-21T20:43:32.000Z (about 1 year ago)
- Last Synced: 2025-04-04T19:54:37.904Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinyvec
A fixed-capacity vector type for Rust with just a single byte of overhead.
Supports a useful subset of `Vec`'s API.
## Usage
```rust
use tinyvec::TinyVec;
// Create a vector with up to 4 elements of type u8
let vec = TinyVec::::new();
// push up to 4 elements
vec.push(1);
vec.push(2);
vec.push(3);
vec.push(4);
// this will panic:
vec.push(5);
```
## Limitations
Stores at most 255 elements. Attempting to `push` when the vector is at capacity will result in a `panic`.