File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -449,16 +449,16 @@ impl CStr {
449449 /// use std::ffi::CStr;
450450 ///
451451 /// # fn main() {
452- /// let cstr = CStr::from_bytes (b"hello\0");
452+ /// let cstr = CStr::from_bytes_with_nul (b"hello\0");
453453 /// assert!(cstr.is_some());
454454 /// # }
455455 /// ```
456456 #[ unstable( feature = "cstr_from_bytes" , reason = "recently added" , issue = "0" ) ]
457- pub fn from_bytes < ' a > ( bytes : & ' a [ u8 ] ) -> Option < & ' a CStr > {
457+ pub fn from_bytes_with_nul < ' a > ( bytes : & ' a [ u8 ] ) -> Option < & ' a CStr > {
458458 if bytes. is_empty ( ) || memchr:: memchr ( 0 , & bytes) != Some ( bytes. len ( ) - 1 ) {
459459 None
460460 } else {
461- Some ( unsafe { Self :: from_bytes_unchecked ( bytes) } )
461+ Some ( unsafe { Self :: from_bytes_with_nul_unchecked ( bytes) } )
462462 }
463463 }
464464
@@ -477,13 +477,13 @@ impl CStr {
477477 /// # fn main() {
478478 /// unsafe {
479479 /// let cstring = CString::new("hello").unwrap();
480- /// let cstr = CStr::from_bytes_unchecked (cstring.to_bytes_with_nul());
480+ /// let cstr = CStr::from_bytes_with_nul_unchecked (cstring.to_bytes_with_nul());
481481 /// assert_eq!(cstr, &*cstring);
482482 /// }
483483 /// # }
484484 /// ```
485485 #[ unstable( feature = "cstr_from_bytes" , reason = "recently added" , issue = "0" ) ]
486- pub unsafe fn from_bytes_unchecked < ' a > ( bytes : & ' a [ u8 ] ) -> & ' a CStr {
486+ pub unsafe fn from_bytes_with_nul_unchecked < ' a > ( bytes : & ' a [ u8 ] ) -> & ' a CStr {
487487 mem:: transmute ( bytes)
488488 }
489489
You can’t perform that action at this time.
0 commit comments