Provide UniquePtr::as_mut
diff --git a/src/unique_ptr.rs b/src/unique_ptr.rs
index f058d5e..ca527d2 100644
--- a/src/unique_ptr.rs
+++ b/src/unique_ptr.rs
@@ -51,6 +51,12 @@
unsafe { T::__get(self.repr).as_ref() }
}
+ /// Returns a mutable reference to the object owned by this UniquePtr if
+ /// any, otherwise None.
+ pub fn as_mut(&mut self) -> Option<&mut T> {
+ unsafe { (T::__get(self.repr) as *mut T).as_mut() }
+ }
+
/// Consumes the UniquePtr, releasing its ownership of the heap-allocated T.
///
/// Matches the behavior of [std::unique_ptr\<T\>::release](https://en.cppreference.com/w/cpp/memory/unique_ptr/release).