Giter VIP home page Giter VIP logo

druid-enum-helpers's People

Contributors

derekdreery avatar luleyleo avatar timothyhollabaugh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

druid-enum-helpers's Issues

Wildcard arms should represent the raw enum insead of ()

fn event_widget() -> impl Widget<Event> {
    match_widget! { Event,
        Event::Click(u32, u32) => Label::dynamic(|data, _| {
            format!("x: {}, y: {}", data.0, data.1)
        }),
        _ => Label::dynamic(|data: &Event, _| format!("key: unhandled"))), // <- THIS
        _ => Label::dynamic(|data: &(), _| format!("key: unhandled"))), // <- NOT THIS
    }
}

match_widget! does not support lints

Code like this will not warn about dead match arms:

let matcher = match_widget! { Event,
    Event::Click(u32, u32) => Label::dynamic(
        |data: &(u32, u32), _| format!("Click at x={}, y={}", data.0, data.1)
    ),
    _ => SizedBox::empty(),
    Event::Key(char) => {
        Button::new(|data: &char, _: &_| format!("'{}' Key", data))
            .on_click(|_, data, _| println!("'{}' Key was clicked", data))
    },
    _i => SizedBox::empty(),
    _ => SizedBox::empty(),
};

Type inference is broken by the lens

let matcher = match_widget! { Event,
    Event::Click(u32, u32) => Label::dynamic(
        |data: &(u32, u32), _| format!("Click at x={}, y={}", data.0, data.1)
    ),
    Event::Key(char) => {
        Button::new(|data: &char, _: &_| format!("'{}' Key", data))
            .on_click(|_, _, _| println!("Key was clicked"))
    },
    Event::Unknown => SizedBox::empty(),
};

should just be

let matcher = match_widget! { Event,
    Event::Click(u32, u32) => Label::dynamic(
        |data, _| format!("Click at x={}, y={}", data.0, data.1)
    ),
    Event::Key(char) => {
        Button::new(|data,  _| format!("'{}' Key", data))
            .on_click(|_, _, _| println!("Key was clicked"))
    },
    Event::Unknown => SizedBox::empty(),
};

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.