Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lokathor/tinyvec
Just, really the littlest Vec you could need. So smol.
https://github.com/lokathor/tinyvec
rust zlib-license
Last synced: 5 days ago
JSON representation
Just, really the littlest Vec you could need. So smol.
- Host: GitHub
- URL: https://github.com/lokathor/tinyvec
- Owner: Lokathor
- License: apache-2.0
- Created: 2020-01-07T01:44:20.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-08-21T18:37:12.000Z (4 months ago)
- Last Synced: 2024-12-13T16:36:22.214Z (10 days ago)
- Topics: rust, zlib-license
- Language: Rust
- Homepage: https://docs.rs/tinyvec
- Size: 438 KB
- Stars: 655
- Watchers: 11
- Forks: 49
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE.md
Awesome Lists containing this project
README
[![License:Zlib](https://img.shields.io/badge/License-Zlib-brightgreen.svg)](https://opensource.org/licenses/Zlib)
![Minimum Rust Version](https://img.shields.io/badge/Min%20Rust-1.47-green.svg)
[![crates.io](https://img.shields.io/crates/v/tinyvec.svg)](https://crates.io/crates/tinyvec)
[![docs.rs](https://docs.rs/tinyvec/badge.svg)](https://docs.rs/tinyvec/)![Unsafe-Zero-Percent](https://img.shields.io/badge/Unsafety-0%25-brightgreen.svg)
# tinyvec
A 100% safe crate of vec-like types.
Not just safe at the public API boundary, fully safe for all internal code too: `#![forbid(unsafe_code)]`The provided types are as follows:
* `ArrayVec` is an array-backed vec-like data structure. It panics on overflow.
* `SliceVec` is similar, but using a `&mut [T]` as the data backing.
* `TinyVec` (`alloc` feature) is an enum that's either an `Inline(ArrayVec)` or a `Heap(Vec)`.
If a `TinyVec` is `Inline` and would overflow its array it automatically transitions to `Heap` and continues whatever it was doing.To attain this "100% safe code" status there is one compromise: the element type of the vecs must implement `Default`.
For more API details, please see [the docs.rs documentation](https://docs.rs/tinyvec/)
## `tinyvec` Alternatives?
Maybe you don't want to use `tinyvec`, there's other crates you might use instead!
* [arrayvec](https://docs.rs/arrayvec) is a crate with array-backed structures.
* [smallvec](https://docs.rs/smallvec) is a crate where the array-backed data can be moved to the heap on overflow.The main difference is that both of those crates use `unsafe` code.
This mostly allows them to get rid of the `Default` limitation for elements that `tinyvec` imposes.
The `smallvec` and `arrayvec` crates are generally correct, but there's been occasional bugs leading to UB.
With `tinyvec`, any uncaught bugs *can't* lead to UB, because the crate is safe code all the way through.
If you want that absolute level of assurance against UB, use `tinyvec`.