Skip to content

Trard/unhygienic2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unhygienic2

A dead simple macro to erase macro hygiene. This stringifies the input, then reparses it in the caller's context.

First unhygienic based on proc_macro_hack. Since 1.45 Rust have native support #[proc_macro]. Therefore, proc_macro_hack isn't neeeded.

Example

use unhygienic2::unhygienic;

macro_rules! declare {
    ($exp:expr) => {
        unhygienic! {
            fn func() -> i32 {
                let a = 5;

                $exp
            }
        }
    }
}

declare!({ a + 1 });

fn main() {
    assert_eq!(func(), 6);
}

About

A dead simple macro to erase macro hygiene

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages