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