Files
physical/src/cell.rs
T
zack 6fc828e864 Initial node implementation (#4)
Reviewed-on: #4
Co-authored-by: Zack <zack@bfpower.io>
Co-committed-by: Zack <zack@bfpower.io>
2023-07-19 18:09:13 +00:00

21 lines
505 B
Rust

use core::cell::Cell;
/// Provides a view only reference to a [Cell].
/// Useful alternative to `&Cell` when an API wants to control where a [Cell]s value can be set.
#[derive(Copy, Clone)]
pub struct CellView<'a, T: Copy>(&'a Cell<T>);
impl<T: Copy> CellView<'_, T> {
#[inline(always)]
pub fn get(self) -> T {
self.0.get()
}
}
impl<'a, T: Copy> From<&'a Cell<T>> for CellView<'a, T> {
#[inline(always)]
fn from(value: &'a Cell<T>) -> Self {
CellView(value)
}
}