Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Planet<T> {
- i: T
- }
- trait Spinner<T> {
- fn spin(&self, value: T);
- }
- impl<T> Spinner<T> for Planet<T> {
- fn spin(&self, _value: T) {}
- }
- // foo2 fails: Due to lifetime of local variable being less than 'a
- fn foo2<'a>(t: &'a Spinner<&'a i32>) {
- let x: i32 = 10;
- t.spin(&x);
- }
- // foo1 passes: But here also the lifetime of local variable is less than 'a?
- fn foo1<'a>(t: &'a Planet<&'a i32>) {
- let x: i32 = 10;
- t.spin(&x);
- }
- fn main() {}
Add Comment
Please, Sign In to add comment