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

Cow::clone should do shallow copies? #34284

Closed
brson opened this Issue Jun 15, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@brson
Copy link
Contributor

brson commented Jun 15, 2016

In a recent PR it was pointed out that cloning a Cow shouldn't ever need to allocate - the cloned Cow could borrow a pointer to the original.

@bluss

This comment has been minimized.

Copy link
Contributor

bluss commented Jun 15, 2016

No, this is not possible

impl<'a, T> Clone for Cow<'a, T> {
    fn clone<'b>(&'b self) -> Cow<'a, T> { ... }
}

The owned variant can only be borrowed for the scope 'b, not the scope 'a that is required.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jun 15, 2016

Aha excellent point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.