https://github.com/zmitchell/wickerman
Learn Rust procedural macros with Nic Cage
https://github.com/zmitchell/wickerman
bees macros procedural-macros rust rust-macro
Last synced: 10 months ago
JSON representation
Learn Rust procedural macros with Nic Cage
- Host: GitHub
- URL: https://github.com/zmitchell/wickerman
- Owner: zmitchell
- License: apache-2.0
- Created: 2018-02-05T03:05:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-11T12:44:15.000Z (over 6 years ago)
- Last Synced: 2025-04-02T15:11:15.016Z (11 months ago)
- Topics: bees, macros, procedural-macros, rust, rust-macro
- Language: Rust
- Homepage:
- Size: 130 KB
- Stars: 22
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# 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:
* [Introdution to Procedural Macros](https://tinkering.xyz/introduction-to-proc-macros/)
To see the error message above, add `wickerman` as a dependency in your `Cargo.toml`:
```toml
# Cargo.toml
[dependencies]
wickerman = {git = "https://github.com/zmitchell/wickerman"}
```
then use `wickerman::wickerman` in a crate with procedural macros enabled:
```rust
#![feature(proc_macro)]
extern crate wickerman;
use wickerman::wickerman;
```
and, finally, apply the `#[wickerman]` attribute to a struct containing a field named "bees".
```rust
#[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.
```toml
# Cargo.toml
[dependencies]
wickerman = {git = "https://github.com/zmitchell/wickerman", features = ["go-nuts"]}
```
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
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.