Skip to content

Commit eb7330b

Browse files
committed
Fix various clippy warnings
1 parent 224ac40 commit eb7330b

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

data-url/tests/wpt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn run_data_url(
1717
if let Some(expected_mime) = expected_mime {
1818
let url = url.unwrap();
1919
let (body, _) = url.decode_to_vec().unwrap();
20-
if expected_mime == "" {
20+
if expected_mime.is_empty() {
2121
assert_eq!(url.mime_type().to_string(), "text/plain;charset=US-ASCII")
2222
} else {
2323
assert_eq!(url.mime_type().to_string(), expected_mime)
@@ -41,7 +41,7 @@ where
4141
enum TestCase {
4242
Two(String, Option<String>),
4343
Three(String, Option<String>, Vec<u8>),
44-
};
44+
}
4545

4646
let v: Vec<TestCase> = serde_json::from_str(include_str!("data-urls.json")).unwrap();
4747
for test in v {

idna/tests/uts46.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use idna::Errors;
1414
pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
1515
// https://www.unicode.org/Public/idna/13.0.0/IdnaTestV2.txt
1616
for (i, line) in include_str!("IdnaTestV2.txt").lines().enumerate() {
17-
if line == "" || line.starts_with('#') {
17+
if line.is_empty() || line.starts_with('#') {
1818
continue;
1919
}
2020

url/src/host.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,11 @@ fn parse_ipv4number(mut input: &str) -> Result<Option<u32>, ()> {
263263
// So instead we check if the input looks like a real number and only return
264264
// an error when it's an overflow.
265265
let valid_number = match r {
266-
8 => input.chars().all(|c| c >= '0' && c <= '7'),
267-
10 => input.chars().all(|c| c >= '0' && c <= '9'),
268-
16 => input
269-
.chars()
270-
.all(|c| (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')),
266+
8 => input.chars().all(|c| ('0'..='7').contains(&c)),
267+
10 => input.chars().all(|c| ('0'..='9').contains(&c)),
268+
16 => input.chars().all(|c| {
269+
('0'..='9').contains(&c) || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
270+
}),
271271
_ => false,
272272
};
273273

@@ -302,7 +302,7 @@ fn parse_ipv4addr(input: &str) -> ParseResult<Option<Ipv4Addr>> {
302302
let mut numbers: Vec<u32> = Vec::new();
303303
let mut overflow = false;
304304
for part in parts {
305-
if part == "" {
305+
if part.is_empty() {
306306
return Ok(None);
307307
}
308308
match parse_ipv4number(part) {

url/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ impl Url {
16571657
}
16581658

16591659
if let Some(host) = host {
1660-
if host == "" && SchemeType::from(self.scheme()).is_special() {
1660+
if host.is_empty() && SchemeType::from(self.scheme()).is_special() {
16611661
return Err(ParseError::EmptyHost);
16621662
}
16631663
let mut host_substr = host;

url/src/parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,17 @@ impl<'i> Input<'i> {
295295
}
296296

297297
pub trait Pattern {
298-
fn split_prefix<'i>(self, input: &mut Input<'i>) -> bool;
298+
fn split_prefix(self, input: &mut Input) -> bool;
299299
}
300300

301301
impl Pattern for char {
302-
fn split_prefix<'i>(self, input: &mut Input<'i>) -> bool {
302+
fn split_prefix(self, input: &mut Input) -> bool {
303303
input.next() == Some(self)
304304
}
305305
}
306306

307307
impl<'a> Pattern for &'a str {
308-
fn split_prefix<'i>(self, input: &mut Input<'i>) -> bool {
308+
fn split_prefix(self, input: &mut Input) -> bool {
309309
for c in self.chars() {
310310
if input.next() != Some(c) {
311311
return false;
@@ -316,7 +316,7 @@ impl<'a> Pattern for &'a str {
316316
}
317317

318318
impl<F: FnMut(char) -> bool> Pattern for F {
319-
fn split_prefix<'i>(self, input: &mut Input<'i>) -> bool {
319+
fn split_prefix(self, input: &mut Input) -> bool {
320320
input.next().map_or(false, self)
321321
}
322322
}
@@ -1071,7 +1071,7 @@ impl<'a> Parser<'a> {
10711071
Ok((has_host, host, remaining))
10721072
}
10731073

1074-
pub fn file_host<'i>(input: Input<'i>) -> ParseResult<(bool, String, Input<'i>)> {
1074+
pub fn file_host(input: Input) -> ParseResult<(bool, String, Input)> {
10751075
// Undo the Input abstraction here to avoid allocating in the common case
10761076
// where the host part of the input does not contain any tab or newline
10771077
let input_str = input.chars.as_str();

0 commit comments

Comments
 (0)