autocommit 2022-01-28 03:35:35 CET
This commit is contained in:
parent
c340df0d08
commit
a5573b8a3a
36 changed files with 3046 additions and 114 deletions
22
src/utils/bitflags.rs
Normal file
22
src/utils/bitflags.rs
Normal 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
21
src/utils/debug_fn.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue