Giter VIP home page Giter VIP logo

Comments (5)

rhoot avatar rhoot commented on June 15, 2024

Seems like this is not possible until the associated_consts feature is done and allowed in stable rust. Looking forward to that!

from bitflags.

gsingh93 avatar gsingh93 commented on June 15, 2024

Will namespaced constants using associated consts allow us to pattern match exhaustively on the flag names?

from bitflags.

felixc avatar felixc commented on June 15, 2024

In the interim, wrapping the whole definition in a mod at least gets you a namespace. E.g.:

pub mod xmp_packet_fmt {
    bitflags! {
        pub flags GExiv2XmpFormatFlags: u64 {
            const OMIT_PACKET_WRAPPER   = 0x0010,
            const READ_ONLY_PACKET      = 0x0020,
            const USE_COMPACT_FORMAT    = 0x0040,
            const INCLUDE_THUMBNAIL_PAD = 0x0100,
            const EXACT_PACKET_LENGTH   = 0x0200,
            const WRITE_ALIAS_COMMENTS  = 0x0400,
            const OMIT_ALL_FORMATTING   = 0x0800,
        }
    }
}

println!("{:?}", xmp_packet_fmt::INCLUDE_THUMBNAIL_PAD);

from bitflags.

dtolnay avatar dtolnay commented on June 15, 2024

Will namespaced constants using associated consts allow us to pattern match exhaustively on the flag names?

No I don't think so.

from bitflags.

dtolnay avatar dtolnay commented on June 15, 2024

It seems pretty clear at this point that associated constants are the answer to this, so let's track namespacing as part of #21.

from bitflags.

Related Issues (20)

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.