2018-12-11 21:49:40 +00:00
|
|
|
trait Bazinga {}
|
|
|
|
impl<F> Bazinga for F {}
|
2018-07-27 21:46:16 +00:00
|
|
|
|
|
|
|
fn produce1<'a>(data: &'a u32) -> impl Bazinga + 'a {
|
|
|
|
let x = move || {
|
|
|
|
let _data: &'a u32 = data;
|
|
|
|
};
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
|
|
|
fn produce2<'a>(data: &'a mut Vec<&'a u32>, value: &'a u32) -> impl Bazinga + 'a {
|
|
|
|
let x = move || {
|
|
|
|
let value: &'a u32 = value;
|
|
|
|
data.push(value);
|
|
|
|
};
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
|
|
|
fn produce3<'a, 'b: 'a>(data: &'a mut Vec<&'a u32>, value: &'b u32) -> impl Bazinga + 'a {
|
|
|
|
let x = move || {
|
|
|
|
let value: &'a u32 = value;
|
|
|
|
data.push(value);
|
|
|
|
};
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
|
|
|
fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> impl Bazinga + 'b {
|
2018-09-15 17:30:29 +00:00
|
|
|
let x = move || {
|
2018-07-27 21:46:16 +00:00
|
|
|
let value: &'a u32 = value;
|
2022-02-14 16:10:22 +00:00
|
|
|
data.push(value); //~ ERROR lifetime may not live long enough
|
2018-07-27 21:46:16 +00:00
|
|
|
};
|
2022-02-14 16:10:22 +00:00
|
|
|
x
|
2018-07-27 21:46:16 +00:00
|
|
|
}
|
|
|
|
|
2018-12-11 21:49:40 +00:00
|
|
|
fn main() {}
|