@@ -16,6 +16,18 @@ use crate::runtime::{self, Object};
1616///
1717/// This is guaranteed to have the same size as the underlying pointer.
1818///
19+ /// # Cloning and [`Retained`]
20+ ///
21+ /// This does not implement [`Clone`], but [`Retained`] has a [`From`]
22+ /// implementation to convert from this, so you can easily reliquish ownership
23+ /// and work with a normal [`Retained`] pointer.
24+ ///
25+ /// ```no_run
26+ /// let obj: Owned<T> = ...;
27+ /// let retained: Retained<T> = obj.into();
28+ /// let cloned: Retained<T> = retained.clone();
29+ /// ```
30+ ///
1931/// TODO: Explain similarities to [`Box`].
2032///
2133/// TODO: Explain this vs. [`Retained`]
@@ -43,7 +55,8 @@ impl<T> Owned<T> {
4355 /// else, usually Objective-C methods like `init`, `alloc`, `new`, or
4456 /// `copy`).
4557 ///
46- /// Additionally, there must be no other pointers to the same object.
58+ /// Additionally, there must be no other pointers or references to the same
59+ /// object, and the given reference must not be used afterwards.
4760 ///
4861 /// # Example
4962 ///
@@ -55,6 +68,8 @@ impl<T> Owned<T> {
5568 /// ```
5669 ///
5770 /// TODO: Something about there not being other references.
71+ // Note: The fact that we take a `&mut` here is more of a lint; the lifetime
72+ // information is lost, so whatever produced the reference can still be
5873 #[ inline]
5974 pub unsafe fn new ( obj : & mut T ) -> Self {
6075 Self {
0 commit comments