-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compilation error when trying to drop with cyclic lifetimes #50
Comments
This is likely that |
Maybe rules are not so strict, since |
However, if I understand correctly, we will have to add unsafe impl<#[may_dangle] 'a, #[may_dangle] T, U> Drop for Cow<'a, T, U> {
fn drop(&mut self) {
// impl . . .
touch data with T and 'a
}
} |
The reason |
That is, it works in use std::borrow::Cow;
use std::marker::PhantomData;
#[derive(Clone)]
struct StrongDropck<'a>(PhantomData<&'a ()>);
impl Drop for StrongDropck<'_> {
fn drop(&mut self) {}
}
struct Data<'a> {
data: StrongDropck<'a>,
follower: Option<Cow<'a, StrongDropck<'a>>>,
}
fn main() {
let mut data = Data {
data: StrongDropck(PhantomData),
follower: None,
};
data.follower = Cow::Borrowed(&data.data).into();
} Then if we impl |
In this code, follower has lifetime
'data
anddata
has lifetime'data
If i use
beef::Cow
– compiler tells me:The text was updated successfully, but these errors were encountered: