1
Fork 0

impl From<&CStr> for CString

This commit is contained in:
arcnmx 2015-12-31 13:56:21 -05:00
parent 43ab6c7d5a
commit 965556d162

View file

@ -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")] #[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
impl ops::Index<ops::RangeFull> for CString { impl ops::Index<ops::RangeFull> for CString {
type Output = CStr; type Output = CStr;
@ -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")] #[unstable(feature = "cstring_asref", reason = "recently added", issue = "0")]
impl AsRef<CStr> for CStr { impl AsRef<CStr> for CStr {
fn as_ref(&self) -> &CStr { fn as_ref(&self) -> &CStr {