From 2df64cb0aebd21790f28cc29d534b9e4a0b00034 Mon Sep 17 00:00:00 2001 From: Scallop Ye Date: Sat, 7 May 2022 13:29:44 +0800 Subject: [PATCH 1/2] Update ucstr.rs --- src/ucstr.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/ucstr.rs b/src/ucstr.rs index 934d158..60907ae 100644 --- a/src/ucstr.rs +++ b/src/ucstr.rs @@ -571,14 +571,9 @@ macro_rules! ucstr_common_impl { /// /// Modifying the container referenced by this string may cause its buffer to be /// reallocated, which would also make any pointers to it invalid. - /// - /// # Safety - /// - /// This method is unsafe because you can violate the invariants of this type when - /// mutating the memory the pointer points to (i.e. by adding interior nul values). #[inline] #[must_use] - pub unsafe fn as_mut_ptr(&mut self) -> *mut $uchar { + pub fn as_mut_ptr(&mut self) -> *mut $uchar { self.inner.as_mut_ptr() } @@ -613,14 +608,9 @@ macro_rules! ucstr_common_impl { /// /// This function is useful for interacting with foreign interfaces which use two /// pointers to refer to a range of elements in memory, as is common in C++. - /// - /// # Safety - /// - /// This method is unsafe because you can violate the invariants of this type when - /// mutating the memory the pointer points to (i.e. by adding interior nul values). #[inline] #[must_use] - pub unsafe fn as_mut_ptr_range(&mut self) -> Range<*mut $uchar> { + pub fn as_mut_ptr_range(&mut self) -> Range<*mut $uchar> { self.inner.as_mut_ptr_range() } From ce34973f7490c2df1c14f94ed09710206cffd8bf Mon Sep 17 00:00:00 2001 From: Scallop Ye Date: Sat, 7 May 2022 13:30:46 +0800 Subject: [PATCH 2/2] Update utfstr.rs --- src/utfstr.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/utfstr.rs b/src/utfstr.rs index 444de29..52e64de 100644 --- a/src/utfstr.rs +++ b/src/utfstr.rs @@ -152,18 +152,9 @@ macro_rules! utfstr_common_impl { /// Converts a mutable string slice to a mutable pointer. /// /// This pointer will be pointing to the first element of the string slice. - /// - /// # Safety - /// - /// This function is unsafe because you can violate the invariants of this type when - /// mutating the slice. The caller must ensure that the contents of the slice is valid - /// UTF before the borrow ends and the underlying string is used. - /// - /// Use of this string type whose contents have been mutated to invalid UTF is - /// undefined behavior. #[inline] #[must_use] - pub unsafe fn as_mut_ptr(&mut self) -> *mut $uchar { + pub fn as_mut_ptr(&mut self) -> *mut $uchar { self.inner.as_mut_ptr() }