@@ -14,13 +14,18 @@ use super::Owned;
1414///
1515/// This is guaranteed to have the same size as the underlying pointer.
1616///
17+ /// TODO: Something about the fact that we haven't made the methods associated
18+ /// for [reasons]???
19+ ///
1720/// ## Caveats
1821///
1922/// If the inner type implements [`Drop`], that implementation will not be
2023/// called, since there is no way to ensure that the Objective-C runtime will
2124/// do so. If you need to run some code when the object is destroyed,
2225/// implement the `dealloc` selector instead.
2326///
27+ /// TODO: Restrict the possible types with some kind of unsafe marker trait?
28+ ///
2429/// TODO: Explain similarities with `Arc` and `RefCell`.
2530#[ repr( transparent) ]
2631pub struct Retained < T > {
@@ -47,7 +52,9 @@ pub struct Retained<T> {
4752 /// https://doc.rust-lang.org/core/ptr/traitalias.Thin.html
4853 ///
4954 /// [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
5158 phantom : PhantomData < T > ,
5259}
5360
@@ -92,6 +99,7 @@ impl<T> Retained<T> {
9299 /// The caller must ensure the given object pointer is valid.
93100 #[ doc( alias = "objc_retain" ) ]
94101 #[ inline]
102+ // TODO: Maybe just take a normal reference, and then this can be safe?
95103 pub unsafe fn retain ( ptr : NonNull < T > ) -> Self {
96104 // SAFETY: The caller upholds that the pointer is valid
97105 let rtn = runtime:: objc_retain ( ptr. as_ptr ( ) as * mut Object ) ;
@@ -215,6 +223,8 @@ impl<T> AsRef<T> for Retained<T> {
215223 }
216224}
217225
226+ // TODO: CoerceUnsized?
227+
218228impl < T > Unpin for Retained < T > { }
219229
220230impl < T > From < Owned < T > > for Retained < T > {
0 commit comments