Skip to content

Commit 72688ea

Browse files
committed
std: Make CString::new unsafe b/c it can mutate a *T ptr
1 parent d6257b3 commit 72688ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/c_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct CString {
2929

3030
impl CString {
3131
/// Create a C String from a pointer.
32-
pub fn new(buf: *libc::c_char, owns_buffer: bool) -> CString {
32+
pub unsafe fn new(buf: *libc::c_char, owns_buffer: bool) -> CString {
3333
CString { buf: buf, owns_buffer_: owns_buffer }
3434
}
3535

@@ -187,7 +187,7 @@ mod tests {
187187

188188
#[test]
189189
fn test_is_null() {
190-
let c_str = CString::new(ptr::null(), false);
190+
let c_str = unsafe { CString::new(ptr::null(), false) };
191191
assert!(c_str.is_null());
192192
assert!(!c_str.is_not_null());
193193
}

0 commit comments

Comments
 (0)