|
17 | 17 |
|
18 | 18 | use crate::{
|
19 | 19 | bindings,
|
20 |
| - error::Result, |
21 | 20 | types::{ForeignOwnable, Opaque},
|
22 | 21 | };
|
23 | 22 | use alloc::boxed::Box;
|
24 | 23 | use core::{
|
| 24 | + alloc::AllocError, |
25 | 25 | fmt,
|
26 | 26 | marker::{PhantomData, Unsize},
|
27 | 27 | mem::{ManuallyDrop, MaybeUninit},
|
@@ -152,7 +152,7 @@ unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> {}
|
152 | 152 |
|
153 | 153 | impl<T> Arc<T> {
|
154 | 154 | /// Constructs a new reference counted instance of `T`.
|
155 |
| - pub fn try_new(contents: T) -> Result<Self> { |
| 155 | + pub fn try_new(contents: T) -> Result<Self, AllocError> { |
156 | 156 | // INVARIANT: The refcount is initialised to a non-zero value.
|
157 | 157 | let value = ArcInner {
|
158 | 158 | // SAFETY: There are no safety requirements for this FFI call.
|
@@ -472,15 +472,15 @@ pub struct UniqueArc<T: ?Sized> {
|
472 | 472 |
|
473 | 473 | impl<T> UniqueArc<T> {
|
474 | 474 | /// Tries to allocate a new [`UniqueArc`] instance.
|
475 |
| - pub fn try_new(value: T) -> Result<Self> { |
| 475 | + pub fn try_new(value: T) -> Result<Self, AllocError> { |
476 | 476 | Ok(Self {
|
477 | 477 | // INVARIANT: The newly-created object has a ref-count of 1.
|
478 | 478 | inner: Arc::try_new(value)?,
|
479 | 479 | })
|
480 | 480 | }
|
481 | 481 |
|
482 | 482 | /// Tries to allocate a new [`UniqueArc`] instance whose contents are not initialised yet.
|
483 |
| - pub fn try_new_uninit() -> Result<UniqueArc<MaybeUninit<T>>> { |
| 483 | + pub fn try_new_uninit() -> Result<UniqueArc<MaybeUninit<T>>, AllocError> { |
484 | 484 | Ok(UniqueArc::<MaybeUninit<T>> {
|
485 | 485 | // INVARIANT: The newly-created object has a ref-count of 1.
|
486 | 486 | inner: Arc::try_new(MaybeUninit::uninit())?,
|
|
0 commit comments