Git Product home page Git Product logo

wickerman's Introduction

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.

wickerman's People

Contributors

dtolnay avatar tejasbubane avatar zmitchell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wickerman's Issues

Errors not generated when applied to non-struct item with doc-comments

If you apply the #[wickerman] attribute to an item that is not a struct, you should see an error:

#[wickerman]
enum Foo { // error: this is not a struct
    Bar,
    Baz,
}

However, if that item has doc-comments, you won't see the error:

/// This doesn't generate an error
#[wickerman]
enum Foo {
    Bar,
    Baz,
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.