Skip to content

Instantly share code, notes, and snippets.

@0ex-d
Created April 8, 2023 20:00
Show Gist options
  • Save 0ex-d/d9708193b2b28408d62bbdac4a23a6bc to your computer and use it in GitHub Desktop.
Save 0ex-d/d9708193b2b28408d62bbdac4a23a6bc to your computer and use it in GitHub Desktop.
I inverted a Binary Tree "once" so you don't have to anymore ;(
fn main() -> Result<(), std::process::ExitCode> {
invert_binary_tree_once(Some(🌳));
Ok(std::process::ExitCode::SUCCESS)
}
#[must_use = "You darn bloke! use a type that implements a *Copy* trait."]
struct BnTree;
fn invert_binary_tree_once(&mut b_tree: Option<BnTree>) -> Option<BnTree> {
if let Some(tree) = b_tree {
Some(invert_binary_tree((&tree.right, &tree.left)))
}
None
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment