-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
change core::borrow::BorrowFrom
to core::borrow::Borrow
#530
Comments
I've found that some methods in the standard library are already named |
Here is a more generic definition: pub trait Borrow<'a, Sized? T> for Sized? {
fn borrow(&'a self) -> T;
} Tweaking the definition of pub trait Str<'a> for Sized? {
fn as_slice(&'a self) -> &'a str;
}
pub impl<'a, T> Str<'a> for T where
T: Borrow<'a, &'a str>
{
fn as_slice(&'a self) -> &'a str {
self.borrow()
}
} |
CC @aturon |
I was about to prep a PR to do exactly this! |
(Note that the original RFC had it as |
Currently blocked on rust-lang/rust#20671 |
Was this closed by rust-lang/rust#22210? @aturon |
It was! Thanks. |
core::borrow::BorrowFrom
is now defined as:The proposal
core::borrow::Borrow
simply swaps the type parameters Owned and Self.A: Borrow<T>
means it is able to borrow a value typed asT
from a value typed asA
.This changes
BorrowFrom::borrow_from(&x)
tox.borrow()
.The text was updated successfully, but these errors were encountered: