Skip to content

Commit 965556d

Browse files
committed
impl From<&CStr> for CString
1 parent 43ab6c7 commit 965556d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libstd/ffi/c_str.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,13 @@ impl ToOwned for CStr {
522522
}
523523
}
524524

525+
#[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
526+
impl<'a> From<&'a CStr> for CString {
527+
fn from(s: &'a CStr) -> CString {
528+
s.to_owned()
529+
}
530+
}
531+
525532
#[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
526533
impl ops::Index<ops::RangeFull> for CString {
527534
type Output = CStr;
@@ -532,13 +539,6 @@ impl ops::Index<ops::RangeFull> for CString {
532539
}
533540
}
534541

535-
#[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
536-
impl<'a, T: ?Sized + AsRef<CStr>> From<&'a T> for CString {
537-
fn from(s: &'a T) -> CString {
538-
s.as_ref().to_owned()
539-
}
540-
}
541-
542542
#[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
543543
impl AsRef<CStr> for CStr {
544544
fn as_ref(&self) -> &CStr {

0 commit comments

Comments
 (0)