From 0439fb348866e8cd8604d480bd623e844fd7b2b0 Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Sun, 6 Apr 2025 21:09:55 -0700 Subject: [PATCH] Rename `from_raw` function for consistency against `alloc` crate --- src/c_string.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c_string.rs b/src/c_string.rs index 7102211d..fe2591fb 100644 --- a/src/c_string.rs +++ b/src/c_string.rs @@ -116,11 +116,11 @@ impl CString { /// BYTES.as_ptr().cast() /// }; /// - /// let copied = unsafe { CString::<14>::from_ptr(HELLO_PTR) }.unwrap(); + /// let copied = unsafe { CString::<14>::from_raw(HELLO_PTR) }.unwrap(); /// /// assert_eq!(copied.to_str(), Ok("Hello, world!")); /// ``` - pub unsafe fn from_ptr(ptr: *const c_char) -> Result { + pub unsafe fn from_raw(ptr: *const c_char) -> Result { let cstr = CStr::from_ptr(ptr).to_bytes_with_nul(); Self::from_bytes_with_nul(cstr)