Skip to content

Commit 347caa1

Browse files
committed
Remove .as_mut_ptr()
Discussion at rust-lang/rust#16772
1 parent 4e86796 commit 347caa1

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

src/c_str.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,6 @@ impl CStrBuf {
249249
self.ptr
250250
}
251251

252-
/// Return a mutable pointer to the NUL-terminated string data.
253-
///
254-
/// `.as_mut_ptr` returns an internal pointer into the `CStrBuf`, and
255-
/// may be invalidated when the `CStrBuf` falls out of scope (the
256-
/// destructor will run, freeing the allocation if there is
257-
/// one).
258-
pub fn as_mut_ptr(&self) -> *mut libc::c_char {
259-
self.ptr as *mut _
260-
}
261-
262252
/// Returns an iterator over the string's bytes.
263253
pub fn iter<'a>(&'a self) -> CChars<'a> {
264254
CChars {
@@ -365,27 +355,6 @@ impl CString {
365355
self.buf.as_ptr()
366356
}
367357

368-
/// Return a mutable pointer to the NUL-terminated string data.
369-
///
370-
/// `.as_mut_ptr` returns an internal pointer into the `CString`, and
371-
/// may be invalidated when the `CString` falls out of scope (the
372-
/// destructor will run, freeing the allocation if there is
373-
/// one).
374-
///
375-
/// ```rust
376-
/// let foo = "some string";
377-
///
378-
/// // right
379-
/// let mut x = foo.to_c_str();
380-
/// let p = x.as_mut_ptr();
381-
///
382-
/// // wrong (the CString will be freed, invalidating `p`)
383-
/// let p = foo.to_c_str().as_mut_ptr();
384-
/// ```
385-
pub fn as_mut_ptr(&self) -> *mut libc::c_char {
386-
self.buf.as_mut_ptr()
387-
}
388-
389358
/// Converts the `CString` into a `&[u8]` without copying.
390359
/// Includes the terminating NUL byte.
391360
#[inline]

0 commit comments

Comments
 (0)