2 releases
Uses old Rust 2015
0.0.2 | Jan 3, 2015 |
---|---|
0.0.1 | Nov 24, 2014 |
#34 in #btree-map
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.
- initial
- collections::vec::Vec::init
- last
- collections::vec::Vec::last
- rest
- collections::vec::Vec::tailn
- union
- collections::vec::Vec::add
- range
- std::iter::range
- map
- std::iter::Map::map
- reduce
- std::iter::Scan::scan
- find
- std::iter::Filter::find
- filter
- std::iter::Filter::filter
- every
- std::iter::Iterator::all
- some
- std::iter::Iterator::any
- contains
- collections::vec::Vec::contains etc
- max
- core::slice::Items::max_by
- min
- core::slice::Items::min_by
- sortBy
- collections::vec::Vec::sort_by
- shuffle
- std::rand::Rng::shuffle
- sample
- std::rand::sample
- size
- std::collections::Collection::len
- keys
- collections::btree::map::BTreeMap::keys
- values
- collections::BTreeMap::values
- has
- collections::BTreeMap::contains_key
underscore-rust appends below functions.
- pairs
- invert
- pick
- omit
- defaults
- first
- without
- intersection
- uniq
- indexOf
- lastIndexOf