Skip to content

Commit 1e39e75

Browse files
committed
Fix clippy warnings
- `clippy::explicit_auto_deref` - `clippy::manual_is_ascii_check` - `clippy::needless_borrowed_reference` - `clippy::needless_lifetimes` - `clippy::partial_eq_none`
1 parent 1c1e406 commit 1e39e75

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

data-url/src/mime.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ impl Mime {
1717
{
1818
self.parameters
1919
.iter()
20-
.find(|&&(ref n, _)| name == &**n)
21-
.map(|&(_, ref v)| &**v)
20+
.find(|&(n, _)| name == &**n)
21+
.map(|(_, v)| &**v)
2222
}
2323
}
2424

@@ -124,7 +124,7 @@ fn parse_parameters(s: &str, parameters: &mut Vec<(String, String)>) {
124124
}
125125

126126
fn contains(parameters: &[(String, String)], name: &str) -> bool {
127-
parameters.iter().any(|&(ref n, _)| n == name)
127+
parameters.iter().any(|(n, _)| n == name)
128128
}
129129

130130
fn valid_value(s: &str) -> bool {
@@ -140,7 +140,7 @@ impl fmt::Display for Mime {
140140
f.write_str(&self.type_)?;
141141
f.write_str("/")?;
142142
f.write_str(&self.subtype)?;
143-
for &(ref name, ref value) in &self.parameters {
143+
for (name, value) in &self.parameters {
144144
f.write_str(";")?;
145145
f.write_str(name)?;
146146
f.write_str("=")?;

form_urlencoded/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl Target for String {
186186

187187
impl<'a> Target for &'a mut String {
188188
fn as_mut_string(&mut self) -> &mut String {
189-
&mut **self
189+
self
190190
}
191191
fn finish(self) -> Self {
192192
self
@@ -282,7 +282,7 @@ impl<'a, T: Target> Serializer<'a, T> {
282282
{
283283
let string = string(&mut self.target);
284284
for pair in iter {
285-
let &(ref k, ref v) = pair.borrow();
285+
let (k, v) = pair.borrow();
286286
append_pair(
287287
string,
288288
self.start_position,

idna/src/uts46.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ fn passes_bidi(label: &str, is_bidi_domain: bool) -> bool {
274274
/// http://www.unicode.org/reports/tr46/#Validity_Criteria
275275
fn check_validity(label: &str, config: Config, errors: &mut Errors) {
276276
let first_char = label.chars().next();
277-
if first_char == None {
277+
if first_char.is_none() {
278278
// Empty string, pass
279279
return;
280280
}
@@ -475,7 +475,7 @@ impl Idna {
475475

476476
/// http://www.unicode.org/reports/tr46/#ToASCII
477477
#[allow(clippy::wrong_self_convention)]
478-
pub fn to_ascii<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
478+
pub fn to_ascii(&mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
479479
let mut errors = self.to_ascii_inner(domain, out);
480480

481481
if self.config.verify_dns_length {
@@ -497,7 +497,7 @@ impl Idna {
497497

498498
/// http://www.unicode.org/reports/tr46/#ToUnicode
499499
#[allow(clippy::wrong_self_convention)]
500-
pub fn to_unicode<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
500+
pub fn to_unicode(&mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
501501
if is_simple(domain) {
502502
out.push_str(domain);
503503
return Errors::default().into();
@@ -685,7 +685,7 @@ impl fmt::Debug for Errors {
685685
if !empty {
686686
f.write_str(", ")?;
687687
}
688-
f.write_str(*name)?;
688+
f.write_str(name)?;
689689
empty = false;
690690
}
691691
}

idna/tests/punycode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn one_test(decoded: &str, encoded: &str) {
4141

4242
fn get_string<'a>(map: &'a Map<String, Value>, key: &str) -> &'a str {
4343
match map.get(&key.to_string()) {
44-
Some(&Value::String(ref s)) => s,
44+
Some(Value::String(s)) => s,
4545
None => "",
4646
_ => panic!(),
4747
}

url/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ impl Url {
601601
}
602602

603603
assert!(self.scheme_end >= 1);
604-
assert!(matches!(self.byte_at(0), b'a'..=b'z' | b'A'..=b'Z'));
604+
assert!(self.byte_at(0).is_ascii_alphabetic());
605605
assert!(self
606606
.slice(1..self.scheme_end)
607607
.chars()
@@ -2848,7 +2848,7 @@ fn file_url_segments_to_pathbuf(
28482848

28492849
// A windows drive letter must end with a slash.
28502850
if bytes.len() > 2
2851-
&& matches!(bytes[bytes.len() - 2], b'a'..=b'z' | b'A'..=b'Z')
2851+
&& bytes[bytes.len() - 2].is_ascii_alphabetic()
28522852
&& matches!(bytes[bytes.len() - 1], b':' | b'|')
28532853
{
28542854
bytes.push(b'/');

url/src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ impl<'a> Parser<'a> {
11561156
return input;
11571157
}
11581158

1159-
if maybe_c != None && maybe_c != Some('/') {
1159+
if maybe_c.is_some() && maybe_c != Some('/') {
11601160
self.serialization.push('/');
11611161
}
11621162
// Otherwise, if c is not the EOF code point:
@@ -1534,7 +1534,7 @@ fn ascii_tab_or_new_line(ch: char) -> bool {
15341534
/// https://url.spec.whatwg.org/#ascii-alpha
15351535
#[inline]
15361536
pub fn ascii_alpha(ch: char) -> bool {
1537-
matches!(ch, 'a'..='z' | 'A'..='Z')
1537+
ch.is_ascii_alphabetic()
15381538
}
15391539

15401540
#[inline]

url/tests/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ fn get<'a>(url: &'a Url, attr: &str) -> &'a str {
228228
}
229229

230230
#[allow(clippy::unit_arg)]
231-
fn set<'a>(url: &'a mut Url, attr: &str, new: &str) {
231+
fn set(url: &mut Url, attr: &str, new: &str) {
232232
let _ = match attr {
233233
"protocol" => quirks::set_protocol(url, new),
234234
"username" => quirks::set_username(url, new),

0 commit comments

Comments
 (0)