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

Method to clone owner when it implements CloneStableAddress #70

Open
dbeckwith opened this issue Oct 17, 2020 · 0 comments
Open

Method to clone owner when it implements CloneStableAddress #70

dbeckwith opened this issue Oct 17, 2020 · 0 comments

Comments

@dbeckwith
Copy link

It would be nice to be able to convert OwningRef<&O, T> to OwningRef<O, T> when O: CloneStableAddress. Example:

impl<O, T> OwningRef<&O, T>
where
    O: CloneStableAddress,
{
    pub fn clone_owner(&self) -> OwningRef<O, T> {
        // SAFETY: safe because the owner implements CloneStableAddress
        unsafe { self.map_owner(Clone::clone) }
    }
}
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

No branches or pull requests

1 participant