1
0
Fork 0
forked from wry/wry

autocommit 2022-02-14 21:13:42 CET

This commit is contained in:
Julian Orth 2022-02-14 21:13:42 +01:00
parent 9b8e1ac29f
commit da6b29f138
44 changed files with 5903 additions and 364 deletions

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

@ -0,0 +1,28 @@
use std::cell::UnsafeCell;
use crate::utils::ptr_ext::MutPtrExt;
pub struct Stack<T> {
vec: UnsafeCell<Vec<T>>,
}
impl<T> Default for Stack<T> {
fn default() -> Self {
Self {
vec: Default::default(),
}
}
}
impl<T> Stack<T> {
pub fn push(&self, v: T) {
unsafe {
self.vec.get().deref_mut().push(v);
}
}
pub fn pop(&self) -> Option<T> {
unsafe {
self.vec.get().deref_mut().pop()
}
}
}