@@ -175,12 +175,14 @@ impl<T: Message + ?Sized, O: Ownership> Id<T, O> {
175
175
///
176
176
/// Returns `None` if the pointer was null.
177
177
///
178
+ ///
178
179
/// # Safety
179
180
///
180
181
/// The caller must ensure the given object has +1 retain count, and that
181
182
/// the object pointer otherwise follows the same safety requirements as
182
183
/// in [`Id::retain`].
183
184
///
185
+ ///
184
186
/// # Example
185
187
///
186
188
/// ```no_run
@@ -309,6 +311,7 @@ impl<T: Message, O: Ownership> Id<T, O> {
309
311
///
310
312
/// Returns `None` if the pointer was null.
311
313
///
314
+ ///
312
315
/// # Safety
313
316
///
314
317
/// The caller must ensure that the ownership is correct; that is, there
@@ -320,6 +323,10 @@ impl<T: Message, O: Ownership> Id<T, O> {
320
323
/// dereferencable and initialized, see the [`std::ptr`] module for more
321
324
/// information).
322
325
///
326
+ /// Finally, if you do not know the concrete type of `T`, it may not be
327
+ /// `'static`, and hence you must ensure that the data that `T` references
328
+ /// lives for as long as `T`.
329
+ ///
323
330
/// [`std::ptr`]: core::ptr
324
331
//
325
332
// This would be illegal:
@@ -580,13 +587,17 @@ impl<T: Message> Id<T, Owned> {
580
587
581
588
/// Promote a shared [`Id`] to an owned one, allowing it to be mutated.
582
589
///
590
+ ///
583
591
/// # Safety
584
592
///
585
593
/// The caller must ensure that there are no other pointers (including
586
594
/// [`WeakId`][`super::WeakId`] pointers) to the same object.
587
595
///
588
596
/// This also means that the given [`Id`] should have a retain count of
589
597
/// exactly 1 (except when autoreleases are involved).
598
+ ///
599
+ /// In general, this is wildly unsafe, do see if you can find a different
600
+ /// solution!
590
601
#[ inline]
591
602
pub unsafe fn from_shared ( obj : Id < T , Shared > ) -> Self {
592
603
// Note: We can't debug_assert retainCount because of autoreleases
0 commit comments