Skip to content

Commit 827cc63

Browse files
committed
Use define_encode_set
1 parent 20bebc2 commit 827cc63

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ assert_eq!(css_url.as_str(), "http://servo.github.io/rust-url/main.css");
112112
#[cfg(feature="heapsize")] #[macro_use] extern crate heapsize;
113113

114114
pub extern crate idna;
115+
#[macro_use]
115116
pub extern crate percent_encoding;
116117

117118
use encoding::EncodingOverride;

src/parser.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,13 @@ use host::{Host, HostInternal};
1919
use percent_encoding::{
2020
utf8_percent_encode, percent_encode,
2121
SIMPLE_ENCODE_SET, DEFAULT_ENCODE_SET, USERINFO_ENCODE_SET, QUERY_ENCODE_SET,
22-
PATH_SEGMENT_ENCODE_SET, EncodeSet
22+
PATH_SEGMENT_ENCODE_SET
2323
};
2424

25-
// The backslash (\) character is treated as a path separator in special URLs
26-
// so it needs to be additionally escaped in that case.
27-
#[derive(Clone)]
28-
struct SPECIAL_PATH_SEGMENT_ENCODE_SET;
29-
30-
impl EncodeSet for SPECIAL_PATH_SEGMENT_ENCODE_SET {
31-
#[inline]
32-
fn contains(&self, byte: u8) -> bool {
33-
match byte {
34-
b'\\' => true,
35-
_ => PATH_SEGMENT_ENCODE_SET.contains(byte)
36-
}
37-
}
25+
define_encode_set! {
26+
// The backslash (\) character is treated as a path separator in special URLs
27+
// so it needs to be additionally escaped in that case.
28+
pub SPECIAL_PATH_SEGMENT_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'\\'}
3829
}
3930

4031
pub type ParseResult<T> = Result<T, ParseError>;

0 commit comments

Comments
 (0)