Skip to content

Commit ea8131d

Browse files
committed
Add cstring_from_cow_cstr and osstring_from_cow_osstr
1 parent 1133a14 commit ea8131d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/libstd/ffi/c_str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,14 @@ impl Borrow<CStr> for CString {
682682
fn borrow(&self) -> &CStr { self }
683683
}
684684

685+
#[stable(feature = "cstring_from_cow_cstr", since = "1.28.0")]
686+
impl<'a> From<Cow<'a, CStr>> for CString {
687+
#[inline]
688+
fn from(s: Cow<'a, CStr>) -> Self {
689+
s.into_owned()
690+
}
691+
}
692+
685693
#[stable(feature = "box_from_c_str", since = "1.17.0")]
686694
impl<'a> From<&'a CStr> for Box<CStr> {
687695
fn from(s: &'a CStr) -> Box<CStr> {

src/libstd/ffi/os_str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,14 @@ impl<'a> From<&'a OsString> for Cow<'a, OsStr> {
688688
}
689689
}
690690

691+
#[stable(feature = "osstring_from_cow_osstr", since = "1.28.0")]
692+
impl<'a> From<Cow<'a, OsStr>> for OsString {
693+
#[inline]
694+
fn from(s: Cow<'a, OsStr>) -> Self {
695+
s.into_owned()
696+
}
697+
}
698+
691699
#[stable(feature = "box_default_extra", since = "1.17.0")]
692700
impl Default for Box<OsStr> {
693701
fn default() -> Box<OsStr> {

0 commit comments

Comments
 (0)