mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
23 lines
336 B
Rust
23 lines
336 B
Rust
#![allow(dead_code)]
|
|
|
|
trait Deref {
|
|
fn get(self) -> isize;
|
|
}
|
|
|
|
impl<'a> Deref for &'a isize {
|
|
fn get(self) -> isize {
|
|
*self
|
|
}
|
|
}
|
|
|
|
fn with<R:Deref, F>(f: F) -> isize where F: FnOnce(&isize) -> R {
|
|
f(&3).get()
|
|
}
|
|
|
|
fn return_it() -> isize {
|
|
with(|o| o) //~ ERROR lifetime may not live long enough
|
|
}
|
|
|
|
fn main() {
|
|
}
|