Skip to content

Commit c70fb93

Browse files
committed
Update example to use CStr::to_string_lossy
1 parent 5c54aa7 commit c70fb93

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/ffi/c_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ use crate::{fmt, ops, slice, str};
7979
///
8080
/// fn my_string_safe() -> String {
8181
/// let cstr = unsafe { CStr::from_ptr(my_string()) };
82-
/// // Get copy-on-write Cow<'_, str>, then guarantee a freshly-owned String allocation
83-
/// String::from_utf8_lossy(cstr.to_bytes()).to_string()
82+
/// // Get a copy-on-write Cow<'_, str>, then guarantee a freshly-owned String allocation
83+
/// cstr.to_string_lossy().to_string()
8484
/// }
8585
///
8686
/// println!("string: {}", my_string_safe());

0 commit comments

Comments
 (0)