Skip to content

Instantly share code, notes, and snippets.

Created December 27, 2016 21:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9b49c340204ff7b322fc03e876775653 to your computer and use it in GitHub Desktop.
Save anonymous/9b49c340204ff7b322fc03e876775653 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
use std::fmt::Debug;
const DEFINITIONS: &'static [&'static str] = &[
"a flaky coating of iron oxide",
"fungal plant disease",
"a reddish-brown color",
];
fn main() {
print_all(DEFINITIONS);
dump(DEFINITIONS);
}
fn print_all<'a, T>(items: T)
where T: IntoIterator<Item=&'a &'a str>
{
for item in items {
println!("{}", item);
}
}
// Excerpt From: Jim Blandy and Jason Orendorff. "Programming Rust."
fn dump<T, U>(t: T)
where T: IntoIterator<Item=U>,
U: Debug
{
for u in t {
println!("{:?}", u);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment