2014-08-28 01:46:52 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
trait Deref {
|
2015-01-08 10:54:35 +00:00
|
|
|
fn get(self) -> isize;
|
2012-07-24 23:23:23 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
impl<'a> Deref for &'a isize {
|
|
|
|
fn get(self) -> isize {
|
2012-07-24 23:23:23 +00:00
|
|
|
*self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
fn with<R:Deref, F>(f: F) -> isize where F: FnOnce(&isize) -> R {
|
2012-07-24 23:23:23 +00:00
|
|
|
f(&3).get()
|
|
|
|
}
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
fn return_it() -> isize {
|
2020-05-20 17:58:41 +00:00
|
|
|
with(|o| o) //~ ERROR lifetime may not live long enough
|
2012-07-24 23:23:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|