Moved CellView to own file.

This commit is contained in:
Zachary Sunforge
2023-04-04 08:39:44 -07:00
parent 3719f81b35
commit d9bc0a8da8
2 changed files with 14 additions and 13 deletions

13
src/cell.rs Normal file
View File

@ -0,0 +1,13 @@
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<'a, T: Copy> CellView<'a, T> {
#[inline]
pub fn get(self) -> T {
self.0.get()
}
}

View File

@ -1,15 +1,3 @@
#![no_std]
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<'a, T: Copy> CellView<'a, T> {
#[inline]
pub fn get(self) -> T {
self.0.get()
}
}
mod cell;