Skip to content

Commit bc3e99f

Browse files
committed
utils: expose ImmutAfterInitCell::try_get_inner()
The `try_get_inner()` function is used to obtain the contents of an `ImmutAfterInitCell` (or to return an error). It should be possible for a caller to obtain a `Result` instead of being forced to derefence and panic if the cell is not initialized. Signed-off-by: Jon Lange <[email protected]>
1 parent 468776d commit bc3e99f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/src/utils/immut_after_init.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ impl<T: Copy> ImmutAfterInitCell<T> {
9595
self.init.store(IMMUT_INITIALIZED, Ordering::Release);
9696
}
9797

98-
fn try_get_inner(&self) -> ImmutAfterInitResult<&T> {
98+
/// Obtains the inner value of the cell, returning `Ok(T)` if the cell is
99+
/// initialized or `Err(ImmutAfterInitError)` if not.
100+
pub fn try_get_inner(&self) -> ImmutAfterInitResult<&T> {
99101
self.check_init()?;
100102
let r = unsafe { (*self.data.get()).assume_init_ref() };
101103
Ok(r)

0 commit comments

Comments
 (0)