Skip to content

Instantly share code, notes, and snippets.

@dcolish
Created June 23, 2013 20:21
Show Gist options
  • Save dcolish/5846398 to your computer and use it in GitHub Desktop.
Save dcolish/5846398 to your computer and use it in GitHub Desktop.
use std::str::*;
use std::vec;
fn main() {
let s = "Hello";
let v = replicate(&s, 10);
println(fmt!("%?", v));
}
fn replicate<'r, T> (el: &'r T, n: uint) -> ~[&'r T] {
vec::from_fn(n, |_| { el })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment