1#![doc = include_str!("../README.md")]
2
3pub use smart_default;
4pub use once_cell;
5pub use parking_lot;
6
7pub mod std_prelude {
9 pub use std::path::{Path, PathBuf};
10 pub use std::fs;
11 pub use std::io;
12 pub use std::thread;
13 pub use std::collections::{HashMap, BTreeMap, HashSet, BTreeSet};
14 pub use std::sync::Arc;
15 pub use std::sync::atomic::*;
16 pub use std::error::Error;
17 pub use std::borrow::Cow;
18 pub use std::time::{Duration, Instant};
19 pub use std::mem;
20 pub use std::fmt;
21 pub use std::env;
22 pub use std::process;
23 pub use std::any::*;
24 pub use std::f32::consts::{
25 PI,
26 FRAC_PI_2,
27 FRAC_PI_3,
28 FRAC_PI_4,
29 FRAC_PI_6,
30 FRAC_PI_8,
31 };
32 pub use std::f64::consts::{
33 PI as PI_F64,
34 FRAC_PI_2 as FRAC_PI_2_F64,
35 FRAC_PI_3 as FRAC_PI_3_F64,
36 FRAC_PI_4 as FRAC_PI_4_F64,
37 FRAC_PI_6 as FRAC_PI_6_F64,
38 FRAC_PI_8 as FRAC_PI_8_F64,
39 };
40}
41
42pub mod prelude {
43 pub use crate::flat;
44 pub use crate::io_add_msg;
45 pub use crate::ShortToString;
46
47 pub use once_cell::sync::Lazy;
48 pub use parking_lot::{Mutex, MutexGuard, MappedMutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard, MappedRwLockReadGuard};
49 pub use smart_default::*;
50}
51
52#[macro_export]
71macro_rules! flat {
72 {$($(#[$attr:meta])* $name:ident ;)*} => {
73 $( $(#[$attr])* mod $name; $(#[$attr])* pub use self::$name::*; )*
74 };
75}
76
77#[macro_export]
79macro_rules! io_add_msg {
80 ($($msg:tt)+) => {
81 |err| std::io::Error::new(err.kind(), format!("{} {err}", format!($($msg)+)))
82 };
83}
84
85pub trait ShortToString {
97 fn s(&self) -> String;
99}
100
101impl ShortToString for str {
102 #[inline]
103 fn s(&self) -> String {
104 self.to_owned()
105 }
106}
107
108impl ShortToString for std::ffi::OsStr {
109 #[inline]
110 fn s(&self) -> String {
111 self.to_string_lossy().to_string()
112 }
113}
114
115impl ShortToString for std::path::Path {
116 #[inline]
117 fn s(&self) -> String {
118 self.to_string_lossy().to_string()
119 }
120}
121
122impl ShortToString for std::ffi::CStr {
123 #[inline]
124 fn s(&self) -> String {
125 self.to_string_lossy().to_string()
126 }
127}
128
129#[inline]
131pub fn default<T: Default>() -> T {
132 T::default()
133}