Skip to content

Instantly share code, notes, and snippets.

@huonw
huonw / echo.rs
Last active December 17, 2015 22:38 — forked from brendanzab/echo.rs
fn main() {
let args = os::args();
match args.tail() {
[~"-n",..strs] => print(str::connect(strs, " ")),
strs => println(str::connect(strs, " ")),
}
}
@huonw
huonw / util.rs
Last active December 17, 2015 20:38 — forked from lilyball/util.rs
// ...
pub trait VecUtil<Elem> {
pub fn grouped<'r>(&'r self, n: uint) -> ~[&'r [Elem]];
}
impl<'self, Elem> VecUtil<Elem> for &'self [Elem] {
fn grouped<'r>(&'r self, n: uint) -> ~[&'r [Elem]] {
if self.is_empty() { return ~[]; }
let mut res = vec::with_capacity((self.len()-1) / n + 1);