Skip to content

Commit

Permalink
Allow old-style bitflags use to fix breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
passcod committed Aug 29, 2018
1 parent 565cd9d commit 6d4f1ab
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ mod debounce;
/// __Windows__
///
/// On Windows a `WRITE` event is emitted when attributes change.
#[allow(missing_docs)]
pub mod op {
bitflags! {
/// Holds a set of bit flags representing the actions for the event.
Expand All @@ -324,6 +325,33 @@ pub mod op {
const RESCAN = 0b1000000;
}
}

pub const CHMOD: Op = Op::CHMOD;
pub const CREATE: Op = Op::CREATE;
pub const REMOVE: Op = Op::REMOVE;
pub const RENAME: Op = Op::RENAME;
pub const WRITE: Op = Op::WRITE;
pub const CLOSE_WRITE: Op = Op::CLOSE_WRITE;
pub const RESCAN: Op = Op::RESCAN;
}

#[cfg(test)]
mod op_test {
#[test] fn mixed_bitflags_form() {
let op = super::op::Op::CHMOD | super::op::WRITE;
assert!(op.contains(super::op::CHMOD));
assert!(op.contains(super::op::Op::WRITE));
}

#[test] fn new_bitflags_form() {
let op = super::op::Op::CHMOD | super::op::Op::WRITE;
assert!(op.contains(super::op::Op::WRITE));
}

#[test] fn old_bitflags_form() {
let op = super::op::CHMOD | super::op::WRITE;
assert!(op.contains(super::op::WRITE));
}
}

/// Event delivered when action occurs on a watched path in _raw_ mode
Expand Down

0 comments on commit 6d4f1ab

Please sign in to comment.