Skip to content

Commit

Permalink
impl From<&CStr> for CString
Browse files Browse the repository at this point in the history
  • Loading branch information
arcnmx committed Dec 31, 2015
1 parent 43ab6c7 commit 965556d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/libstd/ffi/c_str.rs
Expand Up @@ -522,6 +522,13 @@ impl ToOwned for CStr {
}
}

#[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
impl<'a> From<&'a CStr> for CString {
fn from(s: &'a CStr) -> CString {
s.to_owned()
}
}

#[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
impl ops::Index<ops::RangeFull> for CString {
type Output = CStr;
Expand All @@ -532,13 +539,6 @@ impl ops::Index<ops::RangeFull> for CString {
}
}

#[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
impl<'a, T: ?Sized + AsRef<CStr>> From<&'a T> for CString {
fn from(s: &'a T) -> CString {
s.as_ref().to_owned()
}
}

#[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
impl AsRef<CStr> for CStr {
fn as_ref(&self) -> &CStr {
Expand Down

0 comments on commit 965556d

Please sign in to comment.