| @@ -73,6 +73,7 @@ mod std_vendor; · 72 unmodified lines |
| 73 | /// assert_eq!(cloned.b, 20); | 73 | /// assert_eq!(cloned.b, 20); |
| 74 | /// | 74 | /// |
| 75 | /// // The refcount drops to zero when `cloned` goes out of scope, and the memory is freed. | 75 | /// // The refcount drops to zero when `cloned` goes out of scope, and the memory is freed. |
| | 76 | /// # Ok::<(), Error>(()) |
| 76 | /// ``` | 77 | /// ``` |
| 77 | /// | 78 | /// |
| 78 | /// Using `Arc<T>` as the type of `self`: | 79 | /// Using `Arc<T>` as the type of `self`: |
| @@ -98,6 +99,7 @@ mod std_vendor; · 19 unmodified lines |
| 98 | /// let obj = Arc::try_new(Example { a: 10, b: 20 })?; | 99 | /// let obj = Arc::try_new(Example { a: 10, b: 20 })?; |
| 99 | /// obj.use_reference(); | 100 | /// obj.use_reference(); |
| 100 | /// obj.take_over(); | 101 | /// obj.take_over(); |
| | 102 | /// # Ok::<(), Error>(()) |
| 101 | /// ``` | 103 | /// ``` |
| 102 | /// | 104 | /// |
| 103 | /// Coercion from `Arc<Example>` to `Arc<dyn MyTrait>`: | 105 | /// Coercion from `Arc<Example>` to `Arc<dyn MyTrait>`: |
| @@ -121,6 +123,7 @@ mod std_vendor; · 17 unmodified lines |
| 121 | /// | 123 | /// |
| 122 | /// // `coerced` has type `Arc<dyn MyTrait>`. | 124 | /// // `coerced` has type `Arc<dyn MyTrait>`. |
| 123 | /// let coerced: Arc<dyn MyTrait> = obj; | 125 | /// let coerced: Arc<dyn MyTrait> = obj; |
| | 126 | /// # Ok::<(), Error>(()) |
| 124 | /// ``` | 127 | /// ``` |
| 125 | pub struct Arc<T: ?Sized> { | 128 | pub struct Arc<T: ?Sized> { |
| 126 | ptr: NonNull<ArcInner<T>>, | 129 | ptr: NonNull<ArcInner<T>>, |
| @@ -337,7 +340,7 @@ impl<T: ?Sized> From<Pin<UniqueArc<T>>> for Arc<T> { · 210 unmodified lines |
| 337 | /// # Example | 340 | /// # Example |
| 338 | /// | 341 | /// |
| 339 | /// ``` | 342 | /// ``` |
| 340 | /// use crate::sync::{Arc, ArcBorrow}; | 343 | /// use kernel::sync::{Arc, ArcBorrow}; |
| 341 | /// | 344 | /// |
| 342 | /// struct Example; | 345 | /// struct Example; |
| 343 | /// | 346 | /// |
| @@ -350,12 +353,13 @@ impl<T: ?Sized> From<Pin<UniqueArc<T>>> for Arc<T> { · 6 unmodified lines |
| 350 | /// | 353 | /// |
| 351 | /// // Assert that both `obj` and `cloned` point to the same underlying object. | 354 | /// // Assert that both `obj` and `cloned` point to the same underlying object. |
| 352 | /// assert!(core::ptr::eq(&*obj, &*cloned)); | 355 | /// assert!(core::ptr::eq(&*obj, &*cloned)); |
| | 356 | /// # Ok::<(), Error>(()) |
| 353 | /// ``` | 357 | /// ``` |
| 354 | /// | 358 | /// |
| 355 | /// Using `ArcBorrow<T>` as the type of `self`: | 359 | /// Using `ArcBorrow<T>` as the type of `self`: |
| 356 | /// | 360 | /// |
| 357 | /// ``` | 361 | /// ``` |
| 358 | /// use crate::sync::{Arc, ArcBorrow}; | 362 | /// use kernel::sync::{Arc, ArcBorrow}; |
| 359 | /// | 363 | /// |
| 360 | /// struct Example { | 364 | /// struct Example { |
| 361 | /// a: u32, | 365 | /// a: u32, |
| @@ -370,6 +374,7 @@ impl<T: ?Sized> From<Pin<UniqueArc<T>>> for Arc<T> { · 8 unmodified lines |
| 370 | /// | 374 | /// |
| 371 | /// let obj = Arc::try_new(Example { a: 10, b: 20 })?; | 375 | /// let obj = Arc::try_new(Example { a: 10, b: 20 })?; |
| 372 | /// obj.as_arc_borrow().use_reference(); | 376 | /// obj.as_arc_borrow().use_reference(); |
| | 377 | /// # Ok::<(), Error>(()) |
| 373 | /// ``` | 378 | /// ``` |
| 374 | pub struct ArcBorrow<'a, T: ?Sized + 'a> { | 379 | pub struct ArcBorrow<'a, T: ?Sized + 'a> { |
| 375 | inner: NonNull<ArcInner<T>>, | 380 | inner: NonNull<ArcInner<T>>, |