1
Fork 0

Rollup merge of #50170 - burtonageo:more_cow_from, r=alexcrichton

Implement From for more types on Cow

This is basically https://github.com/rust-lang/rust/pull/48191, except that it should be implemented in a way that doesn't break third party crates.
This commit is contained in:
kennytm 2018-05-17 05:22:07 +08:00
commit 8366780164
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
5 changed files with 95 additions and 0 deletions

View file

@ -1504,6 +1504,22 @@ impl<'a> From<PathBuf> for Cow<'a, Path> {
}
}
#[stable(feature = "cow_from_pathbuf_ref", since = "1.28.0")]
impl<'a> From<&'a PathBuf> for Cow<'a, Path> {
#[inline]
fn from(p: &'a PathBuf) -> Cow<'a, Path> {
Cow::Borrowed(p.as_path())
}
}
#[stable(feature = "pathbuf_from_cow_path", since = "1.28.0")]
impl<'a> From<Cow<'a, Path>> for PathBuf {
#[inline]
fn from(p: Cow<'a, Path>) -> Self {
p.into_owned()
}
}
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<PathBuf> for Arc<Path> {
#[inline]