commit
This commit is contained in:
parent
e1246d346d
commit
2f6caa57f0
6 changed files with 72 additions and 0 deletions
22
ch10/lifetime_hypotheses.rs
Normal file
22
ch10/lifetime_hypotheses.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
use std::io;
|
||||
|
||||
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
|
||||
if x.len() > y.len() { x } else { y }
|
||||
}
|
||||
|
||||
fn brap<'b>(x: &'b str, y: &str) -> &'b str {
|
||||
if x.len() > y.len() { x } else { "henkieeeeee" }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let stronk = String::from("stronkman");
|
||||
|
||||
let ln;
|
||||
{
|
||||
let stonks = "stonks";
|
||||
let mut inp = String::new();
|
||||
io::stdin().read_line(&mut inp).expect("Please input a name");
|
||||
ln = longest(&inp, brap(stronk.as_str(), stonks));
|
||||
}
|
||||
println!("The longest of them all: {}", ln);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue