Skip to content

Commit b9f44f6

Browse files
committed
implement ops::Not for AsciiSet
1 parent 360b17e commit b9f44f6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

percent_encoding/src/lib.rs

+17
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ impl ops::Add for AsciiSet {
120120
}
121121
}
122122

123+
impl ops::Not for AsciiSet {
124+
type Output = Self;
125+
126+
fn not(self) -> Self {
127+
let mask = self.mask.map(|chunk| !chunk);
128+
AsciiSet { mask }
129+
}
130+
}
131+
123132
/// The set of 0x00 to 0x1F (C0 controls), and 0x7F (DEL).
124133
///
125134
/// Note that this includes the newline and tab characters, but not the space 0x20.
@@ -508,4 +517,12 @@ mod tests {
508517
let expected = AsciiSet::EMPTY.add(b'A').add(b'B');
509518
assert_eq!(left + right, expected);
510519
}
520+
521+
#[test]
522+
fn not() {
523+
let set = AsciiSet::EMPTY.add(b'A').add(b'B');
524+
let not_set = !set;
525+
assert!(!not_set.contains(b'A'));
526+
assert!(not_set.contains(b'C'));
527+
}
511528
}

0 commit comments

Comments
 (0)