1
0
Fork 0
forked from wry/wry

autocommit 2022-03-26 22:58:30 CET

This commit is contained in:
Julian Orth 2022-03-26 22:58:30 +01:00
parent 3b1b843821
commit 707ff6066c
28 changed files with 2307 additions and 707 deletions

View file

@ -1,5 +1,6 @@
pub trait BitflagsExt {
fn contains(self, other: Self) -> bool;
fn not_contains(self, other: Self) -> bool;
fn intersects(self, other: Self) -> bool;
}
@ -10,6 +11,10 @@ macro_rules! num {
self & other == other
}
fn not_contains(self, other: Self) -> bool {
self & other != other
}
fn intersects(self, other: Self) -> bool {
self & other != 0
}

View file

@ -1,5 +1,6 @@
use ahash::AHashMap;
use std::cell::{RefCell, RefMut};
use std::fmt::{Debug, Formatter};
use std::hash::Hash;
use std::mem;
@ -7,6 +8,12 @@ pub struct CopyHashMap<K, V> {
map: RefCell<AHashMap<K, V>>,
}
impl<K: Debug, V: Debug> Debug for CopyHashMap<K, V> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
self.map.fmt(f)
}
}
impl<K, V> Default for CopyHashMap<K, V> {
fn default() -> Self {
Self {

View file

@ -1,6 +1,7 @@
use crate::utils::ptr_ext::MutPtrExt;
use std::cell::UnsafeCell;
use std::collections::VecDeque;
use std::mem;
pub struct SyncQueue<T> {
el: UnsafeCell<VecDeque<T>>,
@ -28,4 +29,10 @@ impl<T> SyncQueue<T> {
pub fn is_empty(&self) -> bool {
unsafe { self.el.get().deref_mut().is_empty() }
}
pub fn swap(&self, queue: &mut VecDeque<T>) {
unsafe {
mem::swap(self.el.get().deref_mut(), queue);
}
}
}