Skip to content

Commit

Permalink
Rollup merge of rust-lang#51912 - mbrubeck:more_box_slice_clone, r=al…
Browse files Browse the repository at this point in the history
…excrichton

impl Clone for Box<CStr>, Box<OsStr>, Box<Path>

Implements rust-lang#51908.
  • Loading branch information
kennytm authored Jul 12, 2018
2 parents c87e3fe + cdff2f3 commit b317ab1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,14 @@ impl From<Box<CStr>> for CString {
}
}

#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<CStr> {
#[inline]
fn clone(&self) -> Self {
(**self).into()
}
}

#[stable(feature = "box_from_c_string", since = "1.20.0")]
impl From<CString> for Box<CStr> {
#[inline]
Expand Down
8 changes: 8 additions & 0 deletions src/libstd/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,14 @@ impl From<OsString> for Box<OsStr> {
}
}

#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<OsStr> {
#[inline]
fn clone(&self) -> Self {
self.to_os_string().into_boxed_os_str()
}
}

#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<OsString> for Arc<OsStr> {
#[inline]
Expand Down
8 changes: 8 additions & 0 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,14 @@ impl From<PathBuf> for Box<Path> {
}
}

#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<Path> {
#[inline]
fn clone(&self) -> Self {
self.to_path_buf().into_boxed_path()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
fn from(s: &'a T) -> PathBuf {
Expand Down

0 comments on commit b317ab1

Please sign in to comment.