1
0
Fork 0
forked from wry/wry

metal: simplify framebuffer swapchain

This commit is contained in:
Julian Orth 2024-02-19 17:38:09 +01:00
parent 60f2c6e49d
commit 64e133caf6
3 changed files with 38 additions and 11 deletions

28
src/utils/opaque_cell.rs Normal file
View file

@ -0,0 +1,28 @@
use std::{
cell::Cell,
fmt::{Debug, Formatter},
ops::{Deref, DerefMut},
};
#[derive(Default)]
pub struct OpaqueCell<T>(Cell<T>);
impl<T> Deref for OpaqueCell<T> {
type Target = Cell<T>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<T> DerefMut for OpaqueCell<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<T> Debug for OpaqueCell<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "Cell<{}> {{ ... }}", std::any::type_name::<T>())
}
}