@@ -16,6 +16,18 @@ use crate::runtime::{self, Object};
16
16
///
17
17
/// This is guaranteed to have the same size as the underlying pointer.
18
18
///
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
+ ///
19
31
/// TODO: Explain similarities to [`Box`].
20
32
///
21
33
/// TODO: Explain this vs. [`Retained`]
@@ -43,7 +55,8 @@ impl<T> Owned<T> {
43
55
/// else, usually Objective-C methods like `init`, `alloc`, `new`, or
44
56
/// `copy`).
45
57
///
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.
47
60
///
48
61
/// # Example
49
62
///
@@ -55,6 +68,8 @@ impl<T> Owned<T> {
55
68
/// ```
56
69
///
57
70
/// 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
58
73
#[ inline]
59
74
pub unsafe fn new ( obj : & mut T ) -> Self {
60
75
Self {
0 commit comments