Crate code_spells

source ·
Expand description

Do you think Rust macros are a bit like magic? I do too!

With this crate you can live your wizard dreams right in your source code. It aliases some common (and some less common) code snippets to macros named after thematically appropriate spells from Harry Potter.

This enables you to cast geminio!(item) instead of forcing you to call item.clone().

let v1 = vec![erecto!(i32); 5];
let mut v2 = geminio!(&v1);
obliviate!(v1);
accio!(expecto_patronum!(v2.get_mut(0), "Dementors B-gone!")) = 5;

Also aliases unsafe to the macro unforgivable!, because what could be more unforgivable than undefined behaviour?

Macros