Skip to content
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

fn Rav1dPictureDataComponentInner::wrap_buf: Attempt to add lifetimes #1317

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kkysen
Copy link
Collaborator

@kkysen kkysen commented Jul 14, 2024

I'm struggling to figure out the lifetimes here, even though I think they should work. The 'buf lifetime, i.e. the lifetime of Rav1dPictureDataComponentInner::buf, should outlive 'a, where 'a is in &'a Rav1dPictureDataComponent<'buf> when stored in Rav1dPictureDataComponentOffset::data. But things aren't working out. Can anyone else help and figure this out?

@kkysen kkysen marked this pull request as draft July 14, 2024 08:17
@rinon
Copy link
Collaborator

rinon commented Jul 16, 2024

It's not that it needs to outlive 'a there, it's that you're assigning a Rav1dPictureComponent<'buf> and a Rav1dPictureComponent<'static> to the same variable, so the lifetimes in those two types must match (because DisjointMut is invariant).

Sorry I don't have a solution tonight, gonna get to bed, but I'll think on it.

@kkysen
Copy link
Collaborator Author

kkysen commented Jul 16, 2024

It's not that it needs to outlive 'a there, it's that you're assigning a Rav1dPictureComponent<'buf> and a Rav1dPictureComponent<'static> to the same variable, so the lifetimes in those two types must match (because DisjointMut is invariant).

Sorry I don't have a solution tonight, gonna get to bed, but I'll think on it.

Yeah, I realized that. But I don't know how to make the lifetimes exactly the same, or how to not have the lifetime be invariant. But as far as I can tell, the UnsafeCell<T> forces it to be invariant since &mut Ts can be made from it and &mut T is invariant over T. That's my current understanding at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants