Skip to content

Commit 6d4f1ab

Browse files
committed
Allow old-style bitflags use to fix breaking change
1 parent 565cd9d commit 6d4f1ab

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ mod debounce;
300300
/// __Windows__
301301
///
302302
/// On Windows a `WRITE` event is emitted when attributes change.
303+
#[allow(missing_docs)]
303304
pub mod op {
304305
bitflags! {
305306
/// Holds a set of bit flags representing the actions for the event.
@@ -324,6 +325,33 @@ pub mod op {
324325
const RESCAN = 0b1000000;
325326
}
326327
}
328+
329+
pub const CHMOD: Op = Op::CHMOD;
330+
pub const CREATE: Op = Op::CREATE;
331+
pub const REMOVE: Op = Op::REMOVE;
332+
pub const RENAME: Op = Op::RENAME;
333+
pub const WRITE: Op = Op::WRITE;
334+
pub const CLOSE_WRITE: Op = Op::CLOSE_WRITE;
335+
pub const RESCAN: Op = Op::RESCAN;
336+
}
337+
338+
#[cfg(test)]
339+
mod op_test {
340+
#[test] fn mixed_bitflags_form() {
341+
let op = super::op::Op::CHMOD | super::op::WRITE;
342+
assert!(op.contains(super::op::CHMOD));
343+
assert!(op.contains(super::op::Op::WRITE));
344+
}
345+
346+
#[test] fn new_bitflags_form() {
347+
let op = super::op::Op::CHMOD | super::op::Op::WRITE;
348+
assert!(op.contains(super::op::Op::WRITE));
349+
}
350+
351+
#[test] fn old_bitflags_form() {
352+
let op = super::op::CHMOD | super::op::WRITE;
353+
assert!(op.contains(super::op::WRITE));
354+
}
327355
}
328356

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

0 commit comments

Comments
 (0)