rust/tests/ui/single-use-lifetime/issue-117965.rs
2024-01-20 01:22:52 +04:00

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() {}