Skip to content

No clear() method? #418

@Specy

Description

@Specy

The previous major version used to have a clear method (i think?), while migrating to the new version i saw that this method was not present anymore, is this expected? it feels like a common behaviour to include, currently i'm doing this
I used to clear the flags by doing self.bits = 0 in the old version of the library, in the current major version i saw this seems to be a way to do it instead, is there a reason why there is not a .clear() method or similar that unsets all bits?

bitflags! {
    #[wasm_bindgen]
    #[derive(Serialize, Copy, Clone, Debug)]
    pub struct Flags: u16 {
        const Carry    = 1<<1;
        const Overflow = 1<<2;
        const Zero     = 1<<3;
        const Negative = 1<<4;
        const Extend   = 1<<5;
    }
}

impl Flags {
    pub fn clear(&mut self) {
        self.set(Flags::all(), false);
        //or
       *self = Flags::empty();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions