Skip to content

Commit 6c8038d

Browse files
committed
Implemented TryInto<String> for CString
1 parent 5ca44de commit 6c8038d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/alloc/src/ffi/c_str.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,15 @@ impl FromStr for CString {
824824
}
825825
}
826826

827+
impl TryInto<String> for CString {
828+
type Error = IntoStringError;
829+
830+
#[inline]
831+
fn try_into(self) -> Result<String, Self::Error> {
832+
self.into_string()
833+
}
834+
}
835+
827836
#[cfg(not(test))]
828837
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
829838
impl Clone for Box<CStr> {

0 commit comments

Comments
 (0)