Skip to content

bakayu/lessvec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lessvec

A minimal, educational Vec-like collection implemented with only the Rust standard library.

crates.io docs.rs License: MIT Build Status GitHub tag

Quick example

use lessvec::LessVec;

let mut v = LessVec::new();
v.push(1);
v.push(2);
assert_eq!(v.as_slice(), &[1, 2]);

Prelude & macro

lessvec exposes a small prelude with the LessVec type and the lessvec! macro:

use lessvec::prelude::*;

// macro to construct a LessVec (same syntax as std `vec!`)
let v = lessvec![1, 2, 3];
assert_eq!(v.as_slice(), &[1, 2, 3]);

// repeating element form (requires Clone)
let r = lessvec![5; 4];
assert_eq!(r.as_slice(), &[5, 5, 5, 5]);

You can also import the macro directly if you prefer:

use lessvec::lessvec;
let v = lessvec![1, 2, 3];

Running the included example

The repository includes an example at examples/basics.rs. Run it with:

cargo run --example basics

You can run the test suite with:

cargo test

License

MIT LICENSE

About

A custom Vec implementation using the Rust standard library.

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages