Skip to content

Learn Rust procedural macros with Nic Cage

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

zmitchell/wickerman

Repository files navigation

Wickerman

Display error messages inspired by The Wicker Man in your Rust code

About

This crate is meant to illustrate how to make a simple procedural macro in Rust. There is an accompanying blog post that explains what procedural macros are and how to make them:

To see the error message above, add wickerman as a dependency in your Cargo.toml:

# Cargo.toml
[dependencies]
wickerman = {git = "https://github.com/zmitchell/wickerman"}

then use wickerman::wickerman in a crate with procedural macros enabled:

#![feature(proc_macro)]

extern crate wickerman;
use wickerman::wickerman;

and, finally, apply the #[wickerman] attribute to a struct containing a field named "bees".

#[wickerman]
struct Foo {
    bees: i32,
}

To see even more absurd error messages, add the go-nuts feature to Cargo.toml, and apply the attribute to a struct with several fields.

# Cargo.toml
[dependencies]
wickerman = {git = "https://github.com/zmitchell/wickerman", features = ["go-nuts"]}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Learn Rust procedural macros with Nic Cage

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages