X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibstd%2Fffi%2Fc_str.rs;h=3a1853a7a6c623146d4f857dbb78ee55cf60a6c2;hb=4d6dc7f9ba9fe61e38d737b29bfe490e835f6921;hp=587eb0f1cea27d6d531c769ccafef2968562d1d1;hpb=c9f291e4bb664c0cbc5693bb4ec0a5821077393d;p=rust.git diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 587eb0f1cea..3a1853a7a6c 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -119,7 +119,7 @@ pub struct CString { /// Converting a foreign C string into a Rust `String` /// /// ```no_run -/// # #![feature(libc,cstr_to_str)] +/// # #![feature(libc)] /// extern crate libc; /// use std::ffi::CStr; /// @@ -205,7 +205,7 @@ pub unsafe fn from_vec_unchecked(mut v: Vec) -> CString { /// The only appropriate argument is a pointer obtained by calling /// `into_ptr`. The length of the string will be recalculated /// using the pointer. - #[unstable(feature = "cstr_memory", reason = "recently added", + #[unstable(feature = "cstr_memory2", reason = "recently added", issue = "27769")] #[deprecated(since = "1.4.0", reason = "renamed to from_raw")] pub unsafe fn from_ptr(ptr: *const libc::c_char) -> CString { @@ -217,8 +217,7 @@ pub unsafe fn from_ptr(ptr: *const libc::c_char) -> CString { /// The only appropriate argument is a pointer obtained by calling /// `into_raw`. The length of the string will be recalculated /// using the pointer. - #[unstable(feature = "cstr_memory", reason = "recently added", - issue = "27769")] + #[stable(feature = "cstr_memory", since = "1.4.0")] pub unsafe fn from_raw(ptr: *mut libc::c_char) -> CString { let len = libc::strlen(ptr) + 1; // Including the NUL byte let slice = slice::from_raw_parts(ptr, len as usize); @@ -233,7 +232,7 @@ pub unsafe fn from_raw(ptr: *mut libc::c_char) -> CString { /// this string. /// /// Failure to call `from_raw` will lead to a memory leak. - #[unstable(feature = "cstr_memory", reason = "recently added", + #[unstable(feature = "cstr_memory2", reason = "recently added", issue = "27769")] #[deprecated(since = "1.4.0", reason = "renamed to into_raw")] pub fn into_ptr(self) -> *const libc::c_char { @@ -248,8 +247,7 @@ pub fn into_ptr(self) -> *const libc::c_char { /// this string. /// /// Failure to call `from_ptr` will lead to a memory leak. - #[unstable(feature = "cstr_memory", reason = "recently added", - issue = "27769")] + #[stable(feature = "cstr_memory", since = "1.4.0")] pub fn into_raw(self) -> *mut libc::c_char { Box::into_raw(self.inner) as *mut libc::c_char } @@ -429,8 +427,7 @@ pub fn to_bytes_with_nul(&self) -> &[u8] { /// > after a 0-cost cast, but it is planned to alter its definition in the /// > future to perform the length calculation in addition to the UTF-8 /// > check whenever this method is called. - #[unstable(feature = "cstr_to_str", reason = "recently added", - issue = "27764")] + #[stable(feature = "cstr_to_str", since = "1.4.0")] pub fn to_str(&self) -> Result<&str, str::Utf8Error> { // NB: When CStr is changed to perform the length check in .to_bytes() // instead of in from_ptr(), it may be worth considering if this should @@ -450,8 +447,7 @@ pub fn to_str(&self) -> Result<&str, str::Utf8Error> { /// > after a 0-cost cast, but it is planned to alter its definition in the /// > future to perform the length calculation in addition to the UTF-8 /// > check whenever this method is called. - #[unstable(feature = "cstr_to_str", reason = "recently added", - issue = "27764")] + #[stable(feature = "cstr_to_str", since = "1.4.0")] pub fn to_string_lossy(&self) -> Cow { String::from_utf8_lossy(self.to_bytes()) }