Created
December 27, 2016 21:02
-
-
Save anonymous/9b49c340204ff7b322fc03e876775653 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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