Lines Matching defs:ArcBorrow
110 /// use kernel::sync::{Arc, ArcBorrow};
116 /// // Trait has a function whose `self` type is `ArcBorrow<'_, Self>`.
117 /// fn example2(self: ArcBorrow<'_, Self>) {}
295 /// Returns an [`ArcBorrow`] from the given [`Arc`].
297 /// This is useful when the argument of a function call is an [`ArcBorrow`] (e.g., in a method
298 /// receiver), but we have an [`Arc`] instead. Getting an [`ArcBorrow`] is free when optimised.
300 pub fn as_arc_borrow(&self) -> ArcBorrow<'_, T> {
302 // the returned `ArcBorrow` ensures that the object remains alive and that no mutable
304 unsafe { ArcBorrow::new(self.ptr) }
375 type Borrowed<'a> = ArcBorrow<'a, T>;
393 unsafe fn borrow<'a>(ptr: *mut c_void) -> ArcBorrow<'a, T> {
400 unsafe { ArcBorrow::new(inner) }
403 unsafe fn borrow_mut<'a>(ptr: *mut c_void) -> ArcBorrow<'a, T> {
496 /// However, when one may need to increment the refcount, it is preferable to use an `ArcBorrow<T>`
498 /// to a pointer ([`Arc<T>`]) to the object (`T`). An [`ArcBorrow`] eliminates this double
505 /// lifetime of the [`ArcBorrow`] instance.
510 /// use kernel::sync::{Arc, ArcBorrow};
514 /// fn do_something(e: ArcBorrow<'_, Example>) -> Arc<Example> {
526 /// Using `ArcBorrow<T>` as the type of `self`:
529 /// use kernel::sync::{Arc, ArcBorrow};
537 /// fn use_reference(self: ArcBorrow<'_, Self>) {
548 pub struct ArcBorrow<'a, T: ?Sized + 'a> {
553 // This is to allow `ArcBorrow<U>` to be dispatched on when `ArcBorrow<T>` can be coerced into
554 // `ArcBorrow<U>`.
556 impl<T: ?Sized + core::marker::Unsize<U>, U: ?Sized> core::ops::DispatchFromDyn<ArcBorrow<'_, U>>
557 for ArcBorrow<'_, T>
561 impl<T: ?Sized> Clone for ArcBorrow<'_, T> {
567 impl<T: ?Sized> Copy for ArcBorrow<'_, T> {}
569 impl<T: ?Sized> ArcBorrow<'_, T> {
570 /// Creates a new [`ArcBorrow`] instance.
574 /// Callers must ensure the following for the lifetime of the returned [`ArcBorrow`] instance:
585 /// Creates an [`ArcBorrow`] to an [`Arc`] that has previously been deconstructed with
591 /// * For the duration of the lifetime annotated on this `ArcBorrow`, the reference count must
593 /// * For the duration of the lifetime annotated on this `ArcBorrow`, there must not be a
607 impl<T: ?Sized> From<ArcBorrow<'_, T>> for Arc<T> {
608 fn from(b: ArcBorrow<'_, T>) -> Self {
618 impl<T: ?Sized> Deref for ArcBorrow<'_, T> {