diff options
| author | kennytm <kennytm@gmail.com> | 2018-05-17 05:22:07 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-05-17 05:22:07 +0800 |
| commit | 8366780164d062c6cb69d0243e9fcf85a37d548f (patch) | |
| tree | 4aac4c7cc81b3a3fc94aa9cc69a47c3b52202bcd /src/libstd/path.rs | |
| parent | 02aedec72264b76dce679570ea64a799a82ad3ce (diff) | |
| parent | 7c0f664f153f4f41f820723c6b2c758ad5286531 (diff) | |
| download | rust-8366780164d062c6cb69d0243e9fcf85a37d548f.tar.gz rust-8366780164d062c6cb69d0243e9fcf85a37d548f.zip | |
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.
Diffstat (limited to 'src/libstd/path.rs')
| -rw-r--r-- | src/libstd/path.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 86478f0a523..13f55e9261f 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -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] |
