grafix_toolbox/kit/
policies.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
pub mod ext {
	pub use super::{func::file as FS, func::rand, func::slicing, pre::logging, profiling, types::lazy, types::prefetch};
}

pub mod pre {
	pub use super::func::{chksum, ext::*, index::*, logging, n_iter::*, result::*, vec::*};
	pub use super::types::{cached::*, cached_str::*, ext::*, memoized::MemRes, memoized::Memoized};
	pub use super::{math::pre::*, traits::*};

	pub type STR = &'static str;
	pub type Str = Box<str>;
	pub type Astr = std::sync::Arc<str>;

	pub fn Box<T>(v: T) -> Box<T> {
		Box::new(v)
	}
	pub fn Cell<T>(v: T) -> std::cell::Cell<T> {
		std::cell::Cell::new(v)
	}
	pub fn Def<T: Default>() -> T {
		Default::default()
	}

	pub fn type_name<T: ?Sized>() -> String {
		let mut str = std::any::type_name::<T>()
			.split('<')
			.map(|s| [s.split("::").last().unwrap_or(""), "<"].concat())
			.collect::<String>();
		str.pop();
		str
	}
}

#[macro_export]
macro_rules! map_variant {
	($t: pat = $e: expr => $do: expr) => {{
		if let $t = $e {
			Some($do)
		} else {
			None
		}
	}};
}

#[macro_use]
mod traits;
#[macro_use]
mod func;
#[macro_use]
mod types;

pub mod math;
pub mod profiling;
pub mod task;