Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 13, 2024

Conversation

ho-229
Copy link
Contributor

@ho-229 ho-229 commented Jul 9, 2024

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 ho-229 requested a review from a team as a code owner July 9, 2024 16:31
@ho-229 ho-229 requested review from rvolosatovs and removed request for a team July 9, 2024 16:31
@rjzak
Copy link
Member

rjzak commented Jul 9, 2024

LGTM. Could you run git commit -s --amend to add the Signed-off-by flag to the commit, and force push?

Signed-off-by: Ho 229 <ho229v3666@gmail.com>
@ho-229
Copy link
Contributor Author

ho-229 commented Jul 13, 2024

Hello @rjzak , please take a look.

@rjzak rjzak merged commit b497f88 into enarx:main Jul 13, 2024
12 of 13 checks passed
@rjzak
Copy link
Member

rjzak commented Jul 13, 2024

Since I was confused about this at first, I'll link to rust-lang/rust#10910. The leading :: force a path to be an absolute path, vs accidental relative path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants