Skip to content

Commit 0e874dd

Browse files
author
bors-servo
authored
Auto merge of servo#528 - DoumanAsh:ascii_set_remove, r=SimonSapin
percent-encoding: Allow to remove character from AsciiSet Allow to remove character from AsciiSet I liked trait approach better, but if you're going with something like AsciiSet it would be better to allow to remove bytes, as sometimes it is easier to take `NON_ALPHANUMERIC` and remove few necessary characters <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/528) <!-- Reviewable:end -->
2 parents a93e8cb + ed7b991 commit 0e874dd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

percent_encoding/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "percent-encoding"
3-
version = "2.0.0"
3+
version = "2.1.0"
44
authors = ["The rust-url developers"]
55
description = "Percent encoding and decoding"
66
repository = "https://github.com/servo/rust-url/"

percent_encoding/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ impl AsciiSet {
8383
mask[byte as usize / BITS_PER_CHUNK] |= 1 << (byte as usize % BITS_PER_CHUNK);
8484
AsciiSet { mask }
8585
}
86+
87+
pub const fn remove(&self, byte: u8) -> Self {
88+
let mut mask = self.mask;
89+
mask[byte as usize / BITS_PER_CHUNK] &= !(1 << (byte as usize % BITS_PER_CHUNK));
90+
AsciiSet { mask }
91+
}
8692
}
8793

8894
/// The set of 0x00 to 0x1F (C0 controls), and 0x7F (DEL).

0 commit comments

Comments
 (0)