@@ -349,25 +349,25 @@ impl<T: 'static> ForeignOwnable for Arc<T> {
349
349
ManuallyDrop :: new ( self ) . ptr . as_ptr ( ) . cast ( )
350
350
}
351
351
352
- unsafe fn borrow < ' a > ( ptr : * mut crate :: ffi:: c_void ) -> ArcBorrow < ' a , T > {
352
+ unsafe fn from_foreign ( ptr : * mut crate :: ffi:: c_void ) -> Self {
353
353
// SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
354
354
// call to `Self::into_foreign`.
355
355
let inner = unsafe { NonNull :: new_unchecked ( ptr. cast :: < ArcInner < T > > ( ) ) } ;
356
356
357
- // SAFETY: The safety requirements of `from_foreign` ensure that the object remains alive
358
- // for the lifetime of the returned value.
359
- unsafe { ArcBorrow :: new ( inner) }
357
+ // SAFETY: By the safety requirement of this function, we know that `ptr` came from
358
+ // a previous call to `Arc::into_foreign`, which guarantees that `ptr` is valid and
359
+ // holds a reference count increment that is transferrable to us.
360
+ unsafe { Self :: from_inner ( inner) }
360
361
}
361
362
362
- unsafe fn from_foreign ( ptr : * mut crate :: ffi:: c_void ) -> Self {
363
+ unsafe fn borrow < ' a > ( ptr : * mut crate :: ffi:: c_void ) -> ArcBorrow < ' a , T > {
363
364
// SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
364
365
// call to `Self::into_foreign`.
365
366
let inner = unsafe { NonNull :: new_unchecked ( ptr. cast :: < ArcInner < T > > ( ) ) } ;
366
367
367
- // SAFETY: By the safety requirement of this function, we know that `ptr` came from
368
- // a previous call to `Arc::into_foreign`, which guarantees that `ptr` is valid and
369
- // holds a reference count increment that is transferrable to us.
370
- unsafe { Self :: from_inner ( inner) }
368
+ // SAFETY: The safety requirements of `from_foreign` ensure that the object remains alive
369
+ // for the lifetime of the returned value.
370
+ unsafe { ArcBorrow :: new ( inner) }
371
371
}
372
372
}
373
373
0 commit comments