fix no_std

This commit is contained in:
koe 2024-09-01 14:05:21 -05:00 committed by Jeremy Soller
parent cdf1e5b4ee
commit c65f299e87
3 changed files with 11 additions and 9 deletions

View file

@ -1,4 +1,5 @@
use core::fmt::Debug;
use core::mem;
/// Helper for caching a value when the value is optionally present in the 'unused' state.
#[derive(Clone, Debug)]
@ -44,7 +45,7 @@ impl<T: Clone + Debug> Cached<T> {
/// Takes the buffered value if in state `Self::Unused`.
pub fn take_unused(&mut self) -> Option<T> {
if matches!(*self, Self::Unused(_)) {
let Self::Unused(val) = std::mem::replace(self, Self::Empty) else {
let Self::Unused(val) = mem::replace(self, Self::Empty) else {
unreachable!()
};
Some(val)
@ -56,7 +57,7 @@ impl<T: Clone + Debug> Cached<T> {
/// Takes the cached value if in state `Self::Used`.
pub fn take_used(&mut self) -> Option<T> {
if matches!(*self, Self::Used(_)) {
let Self::Used(val) = std::mem::replace(self, Self::Empty) else {
let Self::Used(val) = mem::replace(self, Self::Empty) else {
unreachable!()
};
Some(val)