1
0
Fork 0
forked from wry/wry

autocommit 2022-01-28 03:35:35 CET

This commit is contained in:
Julian Orth 2022-01-28 03:35:35 +01:00
parent c340df0d08
commit a5573b8a3a
36 changed files with 3046 additions and 114 deletions

22
src/utils/bitflags.rs Normal file
View file

@ -0,0 +1,22 @@
pub trait BitflagsExt {
fn contains(self, other: Self) -> bool;
}
macro_rules! num {
($ty:ident) => {
impl BitflagsExt for $ty {
fn contains(self, other: Self) -> bool {
self & other != 0
}
}
};
}
num!(u8);
num!(u16);
num!(u32);
num!(u64);
num!(i8);
num!(i16);
num!(i32);
num!(i64);

21
src/utils/debug_fn.rs Normal file
View file

@ -0,0 +1,21 @@
use std::fmt::{Debug, Formatter};
pub fn debug_fn<F>(f: F) -> impl Debug
where
F: Fn(&mut Formatter<'_>) -> std::fmt::Result,
{
DebugFn { f }
}
struct DebugFn<F> {
f: F,
}
impl<F> Debug for DebugFn<F>
where
F: Fn(&mut Formatter<'_>) -> std::fmt::Result,
{
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
(self.f)(f)
}
}

View file

@ -1,7 +1,9 @@
pub mod asyncevent;
pub mod bitflags;
pub mod buffd;
pub mod clonecell;
pub mod copyhashmap;
pub mod debug_fn;
pub mod errorfmt;
pub mod linkedlist;
pub mod numcell;