rust/tests/ui/regions/regions-glb-free-free.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
787 B
Rust
Raw Normal View History

mod argparse {
pub struct Flag<'a> {
name: &'a str,
2016-03-03 02:32:55 +00:00
pub desc: &'a str,
max_count: usize,
value: usize
}
pub fn flag<'r>(name: &'r str, desc: &'r str) -> Flag<'r> {
Flag { name: name, desc: desc, max_count: 1, value: 0 }
}
impl<'a> Flag<'a> {
pub fn set_desc(self, s: &str) -> Flag<'a> {
2018-12-25 15:56:47 +00:00
Flag { //~ ERROR explicit lifetime required in the type of `s` [E0621]
name: self.name,
desc: s,
max_count: self.max_count,
value: self.value
}
}
}
}
fn main () {
let f : argparse::Flag = argparse::flag("flag", "My flag");
let updated_flag = f.set_desc("My new flag");
assert_eq!(updated_flag.desc, "My new flag");
}