initial commit

This commit is contained in:
ThetaDev 2022-07-21 15:38:53 +02:00
commit 0c76125595
8 changed files with 2979 additions and 0 deletions

65
src/macros.rs Normal file
View file

@ -0,0 +1,65 @@
/// Aggressively prints to the terminal. Useful for rapid debugging in a sea of
/// terminal output.
#[allow(unused_macros)]
macro_rules! highlight {
($($arg:tt)+) => (
{
let indent = ">>>>>";
let focus = ">>>>>>";
let start = ">>>";
let end = ">>>";
println!("{}\n{}\n{} {}\n{}\n{}", start,indent,focus,format!($($arg)+),indent,end);
}
)
}
/// Returns an unwrapped Option if Some() otherwise returns the passed expression
#[allow(unused_macros)]
macro_rules! some_or_bail {
($opt:expr, $ret:expr $(,)?) => {{
match $opt {
Some(stuff) => stuff,
None => {
return $ret;
}
}
}};
}
/// Returns an unwrapped Option if Some() otherwise continues a loop.
#[allow(unused_macros)]
macro_rules! some_or_continue {
($opt:expr $(,)?) => {{
match $opt {
Some(stuff) => stuff,
None => {
continue;
}
}
}};
}
/// Returns an unwrapped Result if Ok() otherwise returns the passed expression
#[allow(unused_macros)]
macro_rules! ok_or_bail {
($result:expr, $ret:expr $(,)?) => {{
match $result {
Ok(stuff) => stuff,
Err(_) => {
return $ret;
}
}
}};
}
#[allow(unused_macros)]
macro_rules! ok_or_continue {
($opt:expr $(,)?) => {{
match $opt {
Ok(stuff) => stuff,
Err(_) => {
continue;
}
}
}};
}