Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings #810

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions data-url/src/mime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ impl Mime {
{
self.parameters
.iter()
.find(|&&(ref n, _)| name == &**n)
.map(|&(_, ref v)| &**v)
.find(|&(n, _)| name == &**n)
.map(|(_, v)| &**v)
}
}

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

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

fn valid_value(s: &str) -> bool {
Expand All @@ -140,7 +140,7 @@ impl fmt::Display for Mime {
f.write_str(&self.type_)?;
f.write_str("/")?;
f.write_str(&self.subtype)?;
for &(ref name, ref value) in &self.parameters {
for (name, value) in &self.parameters {
f.write_str(";")?;
f.write_str(name)?;
f.write_str("=")?;
Expand Down
4 changes: 2 additions & 2 deletions form_urlencoded/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl Target for String {

impl<'a> Target for &'a mut String {
fn as_mut_string(&mut self) -> &mut String {
&mut **self
self
}
fn finish(self) -> Self {
self
Expand Down Expand Up @@ -282,7 +282,7 @@ impl<'a, T: Target> Serializer<'a, T> {
{
let string = string(&mut self.target);
for pair in iter {
let &(ref k, ref v) = pair.borrow();
let (k, v) = pair.borrow();
append_pair(
string,
self.start_position,
Expand Down
8 changes: 4 additions & 4 deletions idna/src/uts46.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ fn passes_bidi(label: &str, is_bidi_domain: bool) -> bool {
/// http://www.unicode.org/reports/tr46/#Validity_Criteria
fn check_validity(label: &str, config: Config, errors: &mut Errors) {
let first_char = label.chars().next();
if first_char == None {
if first_char.is_none() {
// Empty string, pass
return;
}
Expand Down Expand Up @@ -475,7 +475,7 @@ impl Idna {

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

if self.config.verify_dns_length {
Expand All @@ -497,7 +497,7 @@ impl Idna {

/// http://www.unicode.org/reports/tr46/#ToUnicode
#[allow(clippy::wrong_self_convention)]
pub fn to_unicode<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
pub fn to_unicode(&mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
if is_simple(domain) {
out.push_str(domain);
return Errors::default().into();
Expand Down Expand Up @@ -685,7 +685,7 @@ impl fmt::Debug for Errors {
if !empty {
f.write_str(", ")?;
}
f.write_str(*name)?;
f.write_str(name)?;
empty = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion idna/tests/punycode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn one_test(decoded: &str, encoded: &str) {

fn get_string<'a>(map: &'a Map<String, Value>, key: &str) -> &'a str {
match map.get(&key.to_string()) {
Some(&Value::String(ref s)) => s,
Some(Value::String(s)) => s,
None => "",
_ => panic!(),
}
Expand Down
4 changes: 2 additions & 2 deletions url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ impl Url {
}

assert!(self.scheme_end >= 1);
assert!(matches!(self.byte_at(0), b'a'..=b'z' | b'A'..=b'Z'));
assert!(self.byte_at(0).is_ascii_alphabetic());
assert!(self
.slice(1..self.scheme_end)
.chars()
Expand Down Expand Up @@ -2848,7 +2848,7 @@ fn file_url_segments_to_pathbuf(

// A windows drive letter must end with a slash.
if bytes.len() > 2
&& matches!(bytes[bytes.len() - 2], b'a'..=b'z' | b'A'..=b'Z')
&& bytes[bytes.len() - 2].is_ascii_alphabetic()
&& matches!(bytes[bytes.len() - 1], b':' | b'|')
{
bytes.push(b'/');
Expand Down
4 changes: 2 additions & 2 deletions url/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ impl<'a> Parser<'a> {
return input;
}

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

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion url/tests/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ fn get<'a>(url: &'a Url, attr: &str) -> &'a str {
}

#[allow(clippy::unit_arg)]
fn set<'a>(url: &'a mut Url, attr: &str, new: &str) {
fn set(url: &mut Url, attr: &str, new: &str) {
let _ = match attr {
"protocol" => quirks::set_protocol(url, new),
"username" => quirks::set_username(url, new),
Expand Down