Skip to content

BorrowValue auto impl copy/clone helper from borrow #2090

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

Closed
wants to merge 4 commits into from

Conversation

youknowone
Copy link
Member

@youknowone youknowone commented Aug 9, 2020

copy seems ok because *v.borrow_value() is annoying.

I am considering to revert owned and clone. It doesn't give that much values

fn owned_value<Owned>(&'a self) -> Owned
where
Owned: std::borrow::Borrow<<Self::Borrowed as Deref>::Target>,
<Self::Borrowed as Deref>::Target: ToOwned<Owned = Owned>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need a generic for this, can you do -> <<Self::Borrowed as Deref>::Target as ToOwned>::Owned where <Self:: Borrowed as Deref>::Target: ToOwned ?

@youknowone
Copy link
Member Author

@Skinny121 @coolreader18 how do you think about owned_value and cloned_value? keep or remove?

@coolreader18
Copy link
Member

Not sure about owned_value, I feel like it would be more clear to just do .borrow_value().to_owned(); I like cloned_value() more, though maybe it could be called clone_value()?

@coolreader18
Copy link
Member

Although maybe I just don't like owned_value because of the name, I feel like it doesn't communicate that you're converting the value to its owned form. Maybe like borrow_to_owned() or something?

@youknowone youknowone closed this Apr 15, 2022
@youknowone youknowone deleted the borrow-value branch April 15, 2022 15:04
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.

3 participants