From d9bc0a8da8156e4e8558f0593ccaeb79f3ff4070 Mon Sep 17 00:00:00 2001 From: Zachary Sunforge Date: Tue, 4 Apr 2023 08:39:44 -0700 Subject: [PATCH] Moved CellView to own file. --- src/cell.rs | 13 +++++++++++++ src/lib.rs | 14 +------------- 2 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 src/cell.rs diff --git a/src/cell.rs b/src/cell.rs new file mode 100644 index 0000000..0fe56eb --- /dev/null +++ b/src/cell.rs @@ -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); + +impl<'a, T: Copy> CellView<'a, T> { + #[inline] + pub fn get(self) -> T { + self.0.get() + } +} diff --git a/src/lib.rs b/src/lib.rs index 3a721ff..c72a786 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); - -impl<'a, T: Copy> CellView<'a, T> { - #[inline] - pub fn get(self) -> T { - self.0.get() - } -} +mod cell;