Skip to content

Commit 790847c

Browse files
committed
rust: arc: make examples compile
This is part of the effort to minimize the differences of the `rust` branch with respect to mainline in order to eventually drop it. This commit increases the difference, but it is required to make the examples compile (which we do not do yet in mainline). It will land in mainline eventually. Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 050c82d commit 790847c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

rust/kernel/sync/arc.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ use core::{
6767
/// assert_eq!(cloned.b, 20);
6868
///
6969
/// // The refcount drops to zero when `cloned` goes out of scope, and the memory is freed.
70+
///
71+
/// # Ok::<(), Error>(())
7072
/// ```
7173
///
7274
/// Using `Arc<T>` as the type of `self`:
@@ -92,6 +94,8 @@ use core::{
9294
/// let obj = Arc::try_new(Example { a: 10, b: 20 })?;
9395
/// obj.use_reference();
9496
/// obj.take_over();
97+
///
98+
/// # Ok::<(), Error>(())
9599
/// ```
96100
///
97101
/// Coercion from `Arc<Example>` to `Arc<dyn MyTrait>`:
@@ -115,6 +119,8 @@ use core::{
115119
///
116120
/// // `coerced` has type `Arc<dyn MyTrait>`.
117121
/// let coerced: Arc<dyn MyTrait> = obj;
122+
///
123+
/// # Ok::<(), Error>(())
118124
/// ```
119125
pub struct Arc<T: ?Sized> {
120126
ptr: NonNull<ArcInner<T>>,
@@ -394,7 +400,7 @@ impl<T: ?Sized> From<Pin<UniqueArc<T>>> for Arc<T> {
394400
/// # Example
395401
///
396402
/// ```
397-
/// use crate::sync::{Arc, ArcBorrow};
403+
/// use kernel::sync::{Arc, ArcBorrow};
398404
///
399405
/// struct Example;
400406
///
@@ -407,12 +413,14 @@ impl<T: ?Sized> From<Pin<UniqueArc<T>>> for Arc<T> {
407413
///
408414
/// // Assert that both `obj` and `cloned` point to the same underlying object.
409415
/// assert!(core::ptr::eq(&*obj, &*cloned));
416+
///
417+
/// # Ok::<(), Error>(())
410418
/// ```
411419
///
412420
/// Using `ArcBorrow<T>` as the type of `self`:
413421
///
414422
/// ```
415-
/// use crate::sync::{Arc, ArcBorrow};
423+
/// use kernel::sync::{Arc, ArcBorrow};
416424
///
417425
/// struct Example {
418426
/// a: u32,
@@ -427,6 +435,8 @@ impl<T: ?Sized> From<Pin<UniqueArc<T>>> for Arc<T> {
427435
///
428436
/// let obj = Arc::try_new(Example { a: 10, b: 20 })?;
429437
/// obj.as_arc_borrow().use_reference();
438+
///
439+
/// # Ok::<(), Error>(())
430440
/// ```
431441
pub struct ArcBorrow<'a, T: ?Sized + 'a> {
432442
inner: NonNull<ArcInner<T>>,

0 commit comments

Comments
 (0)