Registry / utility / vec1
library1.12.1rscratesunverified

A wrapper around std::Vec that guarantees at least one element.

# Cargo.toml [dependencies] vec1 = "1.12.1"
INSTALL
IMPORT
SIG · VEC1
V
vec1
utilityrustv1.12.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Vec1
use vec1::Vec1;

Creates a Vec1 from a Vec, returning an error if the Vec is empty.

use vec1::Vec1; let v = Vec1::try_from_vec(vec![1, 2, 3]).unwrap(); println!("First element: {}", v[0]);
Debug
Known issues
gotchatry_from_vec returns an error if the input Vec is empty; using unwrap may panic.
fix
Ensure the Vec has at least one element before calling try_from_vec, or handle the error.
affects: >=1.0.0
Upgrade
Version history
1.12.1latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
vec1 — cargo add vec1 · libregistry