@@ -572,8 +572,8 @@ impl CString {
572
572
/// use std::ffi::{CString, CStr};
573
573
///
574
574
/// let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed");
575
- /// let c_str = c_string.as_c_str();
576
- /// assert_eq!(c_str ,
575
+ /// let cstr = c_string.as_c_str();
576
+ /// assert_eq!(cstr ,
577
577
/// CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed"));
578
578
/// ```
579
579
#[ inline]
@@ -994,17 +994,17 @@ impl CStr {
994
994
/// ```
995
995
/// use std::ffi::CStr;
996
996
///
997
- /// let c_str = CStr::from_bytes_with_nul(b"hello");
998
- /// assert!(c_str .is_err());
997
+ /// let cstr = CStr::from_bytes_with_nul(b"hello");
998
+ /// assert!(cstr .is_err());
999
999
/// ```
1000
1000
///
1001
1001
/// Creating a `CStr` with an interior nul byte is an error:
1002
1002
///
1003
1003
/// ```
1004
1004
/// use std::ffi::CStr;
1005
1005
///
1006
- /// let c_str = CStr::from_bytes_with_nul(b"he\0llo\0");
1007
- /// assert!(c_str .is_err());
1006
+ /// let cstr = CStr::from_bytes_with_nul(b"he\0llo\0");
1007
+ /// assert!(cstr .is_err());
1008
1008
/// ```
1009
1009
#[ stable( feature = "cstr_from_bytes" , since = "1.10.0" ) ]
1010
1010
pub fn from_bytes_with_nul ( bytes : & [ u8 ] )
@@ -1111,8 +1111,8 @@ impl CStr {
1111
1111
/// ```
1112
1112
/// use std::ffi::CStr;
1113
1113
///
1114
- /// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1115
- /// assert_eq!(c_str .to_bytes(), b"foo");
1114
+ /// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1115
+ /// assert_eq!(cstr .to_bytes(), b"foo");
1116
1116
/// ```
1117
1117
#[ inline]
1118
1118
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1137,8 +1137,8 @@ impl CStr {
1137
1137
/// ```
1138
1138
/// use std::ffi::CStr;
1139
1139
///
1140
- /// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1141
- /// assert_eq!(c_str .to_bytes_with_nul(), b"foo\0");
1140
+ /// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1141
+ /// assert_eq!(cstr .to_bytes_with_nul(), b"foo\0");
1142
1142
/// ```
1143
1143
#[ inline]
1144
1144
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1164,8 +1164,8 @@ impl CStr {
1164
1164
/// ```
1165
1165
/// use std::ffi::CStr;
1166
1166
///
1167
- /// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1168
- /// assert_eq!(c_str .to_str(), Ok("foo"));
1167
+ /// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1168
+ /// assert_eq!(cstr .to_str(), Ok("foo"));
1169
1169
/// ```
1170
1170
#[ stable( feature = "cstr_to_str" , since = "1.4.0" ) ]
1171
1171
pub fn to_str ( & self ) -> Result < & str , str:: Utf8Error > {
@@ -1205,9 +1205,9 @@ impl CStr {
1205
1205
/// use std::borrow::Cow;
1206
1206
/// use std::ffi::CStr;
1207
1207
///
1208
- /// let c_str = CStr::from_bytes_with_nul(b"Hello World\0")
1208
+ /// let cstr = CStr::from_bytes_with_nul(b"Hello World\0")
1209
1209
/// .expect("CStr::from_bytes_with_nul failed");
1210
- /// assert_eq!(c_str .to_string_lossy(), Cow::Borrowed("Hello World"));
1210
+ /// assert_eq!(cstr .to_string_lossy(), Cow::Borrowed("Hello World"));
1211
1211
/// ```
1212
1212
///
1213
1213
/// Calling `to_string_lossy` on a `CStr` containing invalid UTF-8:
@@ -1216,10 +1216,10 @@ impl CStr {
1216
1216
/// use std::borrow::Cow;
1217
1217
/// use std::ffi::CStr;
1218
1218
///
1219
- /// let c_str = CStr::from_bytes_with_nul(b"Hello \xF0\x90\x80World\0")
1219
+ /// let cstr = CStr::from_bytes_with_nul(b"Hello \xF0\x90\x80World\0")
1220
1220
/// .expect("CStr::from_bytes_with_nul failed");
1221
1221
/// assert_eq!(
1222
- /// c_str .to_string_lossy(),
1222
+ /// cstr .to_string_lossy(),
1223
1223
/// Cow::Owned(String::from("Hello �World")) as Cow<'_, str>
1224
1224
/// );
1225
1225
/// ```
0 commit comments