From 0d33781fbb914438b58065f35f74e59992b1fbcf Mon Sep 17 00:00:00 2001 From: Douman Date: Wed, 24 Jul 2019 07:10:53 +0200 Subject: [PATCH 1/4] percent-encoding: Allow to remove character from AsciiSet --- percent_encoding/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/percent_encoding/lib.rs b/percent_encoding/lib.rs index 170674aa8..27eaf6740 100644 --- a/percent_encoding/lib.rs +++ b/percent_encoding/lib.rs @@ -83,6 +83,12 @@ impl AsciiSet { mask[byte as usize / BITS_PER_CHUNK] |= 1 << (byte as usize % BITS_PER_CHUNK); AsciiSet { mask } } + + pub const fn remove(&self, byte: u8) -> Self { + let mut mask = self.mask; + mask[byte as usize / BITS_PER_CHUNK] &= !(1 << (byte as usize % BITS_PER_CHUNK)); + AsciiSet { mask } + } } /// The set of 0x00 to 0x1F (C0 controls), and 0x7F (DEL). From 976341e3e636ccb37e4db3bd5e53e35ea9557efd Mon Sep 17 00:00:00 2001 From: Douman Date: Wed, 24 Jul 2019 07:21:32 +0200 Subject: [PATCH 2/4] Expose AsciiSet::contains --- percent_encoding/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/percent_encoding/lib.rs b/percent_encoding/lib.rs index 27eaf6740..1bde640e5 100644 --- a/percent_encoding/lib.rs +++ b/percent_encoding/lib.rs @@ -68,7 +68,7 @@ const BITS_PER_CHUNK: usize = 8 * std::mem::size_of::(); impl AsciiSet { /// Called with UTF-8 bytes rather than code points. /// Not used for non-ASCII bytes. - const fn contains(&self, byte: u8) -> bool { + pub const fn contains(&self, byte: u8) -> bool { let chunk = self.mask[byte as usize / BITS_PER_CHUNK]; let mask = 1 << (byte as usize % BITS_PER_CHUNK); (chunk & mask) != 0 From 6b5091fb112b4162dc5a7d1dfea2792c9a006987 Mon Sep 17 00:00:00 2001 From: Douman Date: Wed, 24 Jul 2019 10:56:40 +0200 Subject: [PATCH 3/4] percent-encoding: bump to 2.1.0 --- percent_encoding/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/percent_encoding/Cargo.toml b/percent_encoding/Cargo.toml index a737e333c..e5ff212b1 100644 --- a/percent_encoding/Cargo.toml +++ b/percent_encoding/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "percent-encoding" -version = "2.0.0" +version = "2.1.0" authors = ["The rust-url developers"] description = "Percent encoding and decoding" repository = "https://github.com/servo/rust-url/" From ed7b991f34565f88e6e360c6de99657fbaafa617 Mon Sep 17 00:00:00 2001 From: Douman Date: Wed, 24 Jul 2019 13:39:26 +0200 Subject: [PATCH 4/4] Remove pub access to contains method --- percent_encoding/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/percent_encoding/lib.rs b/percent_encoding/lib.rs index 1bde640e5..27eaf6740 100644 --- a/percent_encoding/lib.rs +++ b/percent_encoding/lib.rs @@ -68,7 +68,7 @@ const BITS_PER_CHUNK: usize = 8 * std::mem::size_of::(); impl AsciiSet { /// Called with UTF-8 bytes rather than code points. /// Not used for non-ASCII bytes. - pub const fn contains(&self, byte: u8) -> bool { + const fn contains(&self, byte: u8) -> bool { let chunk = self.mask[byte as usize / BITS_PER_CHUNK]; let mask = 1 << (byte as usize % BITS_PER_CHUNK); (chunk & mask) != 0