@@ -14,13 +14,18 @@ use super::Owned;
14
14
///
15
15
/// This is guaranteed to have the same size as the underlying pointer.
16
16
///
17
+ /// TODO: Something about the fact that we haven't made the methods associated
18
+ /// for [reasons]???
19
+ ///
17
20
/// ## Caveats
18
21
///
19
22
/// If the inner type implements [`Drop`], that implementation will not be
20
23
/// called, since there is no way to ensure that the Objective-C runtime will
21
24
/// do so. If you need to run some code when the object is destroyed,
22
25
/// implement the `dealloc` selector instead.
23
26
///
27
+ /// TODO: Restrict the possible types with some kind of unsafe marker trait?
28
+ ///
24
29
/// TODO: Explain similarities with `Arc` and `RefCell`.
25
30
#[ repr( transparent) ]
26
31
pub struct Retained < T > {
@@ -47,7 +52,9 @@ pub struct Retained<T> {
47
52
/// https://doc.rust-lang.org/core/ptr/traitalias.Thin.html
48
53
///
49
54
/// [extern-type-rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1861-extern-types.md
50
- ptr : NonNull < T > , // Covariant
55
+ pub ( super ) ptr : NonNull < T > , // Covariant - but should probably be invariant?
56
+ /// TODO:
57
+ /// https://github.com/rust-lang/rfcs/blob/master/text/0769-sound-generic-drop.md#phantom-data
51
58
phantom : PhantomData < T > ,
52
59
}
53
60
@@ -92,6 +99,7 @@ impl<T> Retained<T> {
92
99
/// The caller must ensure the given object pointer is valid.
93
100
#[ doc( alias = "objc_retain" ) ]
94
101
#[ inline]
102
+ // TODO: Maybe just take a normal reference, and then this can be safe?
95
103
pub unsafe fn retain ( ptr : NonNull < T > ) -> Self {
96
104
// SAFETY: The caller upholds that the pointer is valid
97
105
let rtn = runtime:: objc_retain ( ptr. as_ptr ( ) as * mut Object ) ;
@@ -215,6 +223,8 @@ impl<T> AsRef<T> for Retained<T> {
215
223
}
216
224
}
217
225
226
+ // TODO: CoerceUnsized?
227
+
218
228
impl < T > Unpin for Retained < T > { }
219
229
220
230
impl < T > From < Owned < T > > for Retained < T > {
0 commit comments