flagset icon indicating copy to clipboard operation
flagset copied to clipboard

fix: use absolute path references to `rust-core` in flags macro

Open ho-229 opened this issue 7 months ago • 2 comments

The following code is ideal but can not be compiled.

use flagset::{FlagSet, flags};

mod core {}

flags! {
    enum Flags: u8 {
        Foo,
        Bar,
        Baz,
    }
}

struct Container(FlagSet<Flags>);

impl Container {
    fn new(flags: impl Into<FlagSet<Flags>>) -> Container {
        Container(flags.into())
    }
}

assert_eq!(Container::new(Flags::Foo | Flags::Bar).0.bits(), 0b011);
assert_eq!(Container::new(Flags::Foo).0.bits(), 0b001);
assert_eq!(Container::new(None).0.bits(), 0b000);

Absolute path references to rust-core can avoid to use user defined or imported module.

ho-229 avatar Jul 09 '24 16:07 ho-229