File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -292,7 +292,12 @@ impl str {
292
292
/// The caller must ensure that the returned pointer is never written to.
293
293
/// If you need to mutate the contents of the string slice, use [`as_mut_ptr`].
294
294
///
295
+ /// Note that the pointer returned by `as_ptr()` is *not* null-terminated.
296
+ /// See [`std::ffi::CString`] if you need a pointer to a traditional
297
+ /// C-style string.
298
+ ///
295
299
/// [`as_mut_ptr`]: str::as_mut_ptr
300
+ /// [`std::ffi::CString`]: ../std/ffi/struct.CString.html
296
301
///
297
302
/// # Examples
298
303
///
@@ -317,6 +322,12 @@ impl str {
317
322
///
318
323
/// It is your responsibility to make sure that the string slice only gets
319
324
/// modified in a way that it remains valid UTF-8.
325
+ ///
326
+ /// Note that the pointer returned by `as_mut_ptr()` is *not* null-terminated.
327
+ /// See [`std::ffi::CString`] if you need a pointer to a traditional
328
+ /// C-style string.
329
+ ///
330
+ /// [`std::ffi::CString`]: ../std/ffi/struct.CString.html
320
331
#[ stable( feature = "str_as_mut_ptr" , since = "1.36.0" ) ]
321
332
#[ inline]
322
333
pub fn as_mut_ptr ( & mut self ) -> * mut u8 {
You can’t perform that action at this time.
0 commit comments