#utility #vec #js #hash-map #std #btree-map #underscore-rust

underscore

utility library for rust. Inspired by underscore.js.

2 releases

Uses old Rust 2015

0.0.2 Jan 3, 2015
0.0.1 Nov 24, 2014

#34 in #btree-map

MIT license

21KB
205 lines

overview

underscore-rust is utility library for rust. Inspired by underscore.js.

usage

underscore-rust expands std library. You can use the same as standard library.

pub use underscore::vec::VecU;

let sample = vec!(1i, 2, 3);
assert_eq!(1i, *sample.first().unwrap());
pub use underscore::hashmap::HashMapU;

let mut sample = HashMap::new();
sample.insert(1i, 1u);
sample.insert(2i, 2u);
let inverted = sample.invert();
// => HashMap { 1u: 1i, 2u: 2i }
pub use underscore::vec::BTreeMapU;

let mut sample = BTreeMap::new();
sample.insert(1i, 1u);
sample.insert(2i, 2u);
let inverted = sample.invert();
// => BTreeMap { 1u: 1i, 2u: 2i }

underscore-rust now expands only Vec, HashMap, BTreeMap.

document

detail document is here.

std library

rust already has many functions of underscore.js at std library. If you are looking for them, take a look at official document.

underscore-rust appends below functions.

  • pairs
  • invert
  • pick
  • omit
  • defaults
  • first
  • without
  • intersection
  • uniq
  • indexOf
  • lastIndexOf

No runtime deps