| Crates.io | veclite |
| lib.rs | veclite |
| version | 1.0.1 |
| created_at | 2025-07-08 20:29:34.169769+00 |
| updated_at | 2025-08-07 15:44:08.999942+00 |
| description | A lightweight, ergonomic wrapper around Vec |
| homepage | |
| repository | https://github.com/Pjdur/veclite |
| max_upload_size | |
| id | 1743515 |
| size | 18,404 |
A lightweight, ergonomic wrapper around Rust’s Vec<T> that implements Display for pretty printing and provides extra list-like utility methods.
{} formatting — clean, space-separated output instead of debug-style brackets.prepend, remove, get, and more — for convenient, list-like manipulation.Vel for idiomatic code.vel![] macro, just like vec![].Vec<T>, but with extra display and usability power.Debug, PartialEq, Clone, and Default.Cargo.toml[dependencies]
veclite = "1.0.1"
use veclite::{Vel, vel};
let mut v = vel!["hello", "world"];
v.prepend("greetings");
println!("{}", v); // Output: greetings hello world
| Method | Description |
|---|---|
Vel::new() |
Create an empty list |
Vel::from(Vec) |
Convert from a standard Vec<T> |
prepend(value) |
Insert a value at the beginning |
push(value) |
Append a value to the end (via Vec) |
remove(index) |
Remove and return value at index |
get(index) |
Get reference to value at index |
iter() |
Iterate over values |
len() |
Number of elements |
is_empty() |
Check if empty |
| ... Other Vec methods are available directly |
Implements [std::fmt::Display] for space-separated output:
let v = vel![1, 2, 3];
println!("{}", v); // Output: 1 2 3
use veclite::Vel;
fn main() {
let mut v = Vel::new();
v.push(10);
v.push(20);
v.prepend(5);
println!("{}", v); // Output: 5 10 20
if let Some(x) = v.get(1) {
println!("Second element is: {}", x); // Output: Second element is: 10
}
v.remove(0);
println!("{}", v); // Output: 10 20
}
let v = vel![1, 2, 3];
println!("{}", v); // Output: 1 2 3
let names = vel!["Alice".to_string(), "Bob".to_string()];
println!("{}", names); // Output: Alice Bob
let v = vel![1, 2, 3, 4, 5];
for n in &v {
print!("{}-", n);
}
// Output: 1-2-3-4-5-
Q: Does veclite re-export all Vec methods?
A: Most methods are accessible via Deref, so you can use push, iter, sort, etc. directly. For advanced features, use .0 to access the inner Vec.
Q: Can I use veclite with non-displayable types?
A: Yes, but Display formatting requires T: Display. Other methods work for any T.
Q: Why not implement Display for Vec<T> directly?
A: The Rust standard library avoids this to prevent accidental large or slow prints. veclite lets you opt in explicitly.
Bug reports, feature requests, and pull requests are welcome!
Open an issue or PR on GitHub.
Licensed under either of: