mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-18 03:25:55 +00:00
19 lines
353 B
Rust
19 lines
353 B
Rust
#![deny(single_use_lifetimes)]
|
|
|
|
pub enum Data<'a> {
|
|
Borrowed(&'a str),
|
|
Owned(String),
|
|
}
|
|
|
|
impl<'a> Data<'a> {
|
|
pub fn get<'b: 'a>(&'b self) -> &'a str {
|
|
//~^ ERROR lifetime parameter `'b` only used once
|
|
match &self {
|
|
Self::Borrowed(val) => val,
|
|
Self::Owned(val) => &val,
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {}
|