@@ -208,8 +208,13 @@ pub struct CStr {
208
208
}
209
209
210
210
/// An error returned from [`CString::new`] to indicate that a nul byte was found
211
- /// in the vector provided.
211
+ /// in the vector provided. While Rust strings may contain nul bytes in the middle,
212
+ /// C strings can't, as that byte would effectively truncate the string.
212
213
///
214
+ /// This `struct` is created by the [`new`][`CString::new`] method on
215
+ /// [`CString`]. See its documentation for more.
216
+ ///
217
+ /// [`CString`]: struct.CString.html
213
218
/// [`CString::new`]: struct.CString.html#method.new
214
219
///
215
220
/// # Examples
@@ -225,9 +230,15 @@ pub struct NulError(usize, Vec<u8>);
225
230
226
231
/// An error returned from [`CStr::from_bytes_with_nul`] to indicate
227
232
/// that a nul byte was found too early in the slice provided, or one
228
- /// wasn't found at all. The slice used to create a `CStr` must have one
229
- /// and only one nul byte at the end of the slice.
233
+ /// wasn't found at all for the nul terminator. The slice used to
234
+ /// create a `CStr` must have one and only one nul byte at the end of
235
+ /// the slice.
236
+ ///
237
+ /// This `struct` is created by the
238
+ /// [`from_bytes_with_nul`][`CStr::from_bytes_with_nul`] method on
239
+ /// [`CStr`]. See its documentation for more.
230
240
///
241
+ /// [`CStr`]: struct.CStr.html
231
242
/// [`CStr::from_bytes_with_nul`]: struct.CStr.html#method.from_bytes_with_nul
232
243
///
233
244
/// # Examples
@@ -262,9 +273,17 @@ impl FromBytesWithNulError {
262
273
}
263
274
}
264
275
265
- /// An error returned from [`CString::into_string`] to indicate that a UTF-8 error
266
- /// was encountered during the conversion.
276
+ /// An error returned from [`CString::into_string`] to indicate that a
277
+ /// UTF-8 error was encountered during the conversion. `CString` is
278
+ /// just a wrapper over a buffer of bytes with a nul terminator;
279
+ /// [`into_string`][`CString::into_string`] performs UTF-8 validation
280
+ /// and may return this error.
281
+ ///
282
+ /// This `struct` is created by the
283
+ /// [`into_string`][`CString::into_string`] method on [`CString`]. See
284
+ /// its documentation for more.
267
285
///
286
+ /// [`CString`]: struct.CString.html
268
287
/// [`CString::into_string`]: struct.CString.html#method.into_string
269
288
#[ derive( Clone , PartialEq , Eq , Debug ) ]
270
289
#[ stable( feature = "cstring_into" , since = "1.7.0" ) ]
0 commit comments