File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -498,15 +498,17 @@ impl<T: RefCounted> ARef<T> {
498
498
///
499
499
/// struct Empty {}
500
500
///
501
- /// # // SAFETY: TODO.
501
+ /// // SAFETY: The `RefCounted` implementation for `Empty` does not count references
502
+ /// // and never frees the underlying object. Thus we can act as having a
503
+ /// // refcount on the object that we pass to the newly created `ARef`.
502
504
/// unsafe impl RefCounted for Empty {
503
505
/// fn inc_ref(&self) {}
504
506
/// unsafe fn dec_ref(_obj: NonNull<Self>) {}
505
507
/// }
506
508
///
507
509
/// let mut data = Empty {};
508
510
/// let ptr = NonNull::<Empty>::new(&mut data).unwrap();
509
- /// # // SAFETY: TODO .
511
+ /// // SAFETY: We keep `data` around longer than the `ARef` .
510
512
/// let data_ref: ARef<Empty> = unsafe { ARef::from_raw(ptr) };
511
513
/// let raw_ptr: NonNull<Empty> = ARef::into_raw(data_ref);
512
514
///
You can’t perform that action at this time.
0 commit comments