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.

use underscore::vec::VecU;

let sample = vec!(1i, 2, 3);
assert_eq!(1i, *sample.first().unwrap());
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 }
use underscore::btreemap::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