diff --git a/crates/objc2/CHANGELOG.md b/crates/objc2/CHANGELOG.md index c365eb2ce..44465299c 100644 --- a/crates/objc2/CHANGELOG.md +++ b/crates/objc2/CHANGELOG.md @@ -46,6 +46,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `Retained::as_mut_ptr`. - `Retained::autorelease_mut`. - `DeclaredClass::ivars_mut`. + - `ProtocolObject::from_mut`. + - `AutoreleasePool::ptr_as_mut`. * **BREAKING**: Disallow `&mut` message receivers (except in the special case when the object is `AnyObject`, for better backwards compatibility with `objc`). diff --git a/crates/objc2/src/rc/autorelease.rs b/crates/objc2/src/rc/autorelease.rs index 564ed64ee..26da973ca 100644 --- a/crates/objc2/src/rc/autorelease.rs +++ b/crates/objc2/src/rc/autorelease.rs @@ -141,10 +141,6 @@ pub struct AutoreleasePool<'pool> { /// pub fn autorelease(self, s: String) -> &'pool str { /// &*self.0.0.alloc(s) /// } - /// - /// pub fn autorelease_mut(self, s: String) -> &'pool mut str { - /// &mut *self.0.0.alloc(s) - /// } /// } /// /// pub fn autoreleasepool(f: F) -> R @@ -204,8 +200,6 @@ impl<'pool> AutoreleasePool<'pool> { /// objects, since it binds the lifetime of the reference to the pool, and /// does some extra checks when debug assertions are enabled. /// - /// For the mutable counterpart see [`ptr_as_mut`](#method.ptr_as_mut). - /// /// /// # Safety /// @@ -217,26 +211,6 @@ impl<'pool> AutoreleasePool<'pool> { // SAFETY: Checked by the caller unsafe { ptr.as_ref().unwrap_unchecked() } } - - /// Returns a unique reference to the given autoreleased pointer object. - /// - /// This is the preferred way to make mutable references from autoreleased - /// objects, since it binds the lifetime of the reference to the pool, and - /// does some extra checks when debug assertions are enabled. - /// - /// For the shared counterpart see [`ptr_as_ref`](#method.ptr_as_ref). - /// - /// - /// # Safety - /// - /// This is equivalent to `&mut *ptr`, and shares the unsafety of that, - /// except the lifetime is bound to the pool instead of being unbounded. - #[inline] - pub unsafe fn ptr_as_mut(self, ptr: *mut T) -> &'pool mut T { - self.__verify_is_inner(); - // SAFETY: Checked by the caller - unsafe { ptr.as_mut().unwrap_unchecked() } - } } /// We use a macro here so that the documentation is included whether the diff --git a/crates/objc2/src/runtime/protocol_object.rs b/crates/objc2/src/runtime/protocol_object.rs index 6534acbf9..52cde9138 100644 --- a/crates/objc2/src/runtime/protocol_object.rs +++ b/crates/objc2/src/runtime/protocol_object.rs @@ -96,23 +96,6 @@ impl ProtocolObject

{ unsafe { ptr.as_ref() } } - /// Get a mutable type-erased reference from a type implementing a - /// protocol. - #[inline] - pub fn from_mut(obj: &mut T) -> &mut Self - where - P: ImplementedBy, - { - let ptr: NonNull = NonNull::from(obj); - let mut ptr: NonNull = ptr.cast(); - // SAFETY: Same as `as_protocol`. - // - // Since the reference came from a mutable reference to start with, - // returning a mutable reference here is safe (the lifetime of the - // returned reference is bound to the input). - unsafe { ptr.as_mut() } - } - /// Get a type-erased object from a type implementing a protocol. /// /// Soft-deprecated alias of [`ProtocolObject::from_retained`].