Skip to content

Commit 207bc51

Browse files
committed
Clippy fixes
Signed-off-by: Samuel Giddins <[email protected]>
1 parent d9f448d commit 207bc51

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/platform.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Platform<'_> {
3636
parts.pop_back();
3737
}
3838

39-
if parts.len() > 2 && !DOTTED_PATTERN.is_match(&parts.back().unwrap()) {
39+
if parts.len() > 2 && !DOTTED_PATTERN.is_match(parts.back().unwrap()) {
4040
let extra = parts.pop_back().unwrap();
4141
let last = parts.pop_back().unwrap();
4242
let e = last.as_ptr();
@@ -51,7 +51,7 @@ impl Platform<'_> {
5151
if cpu.is_empty() {
5252
panic!("empty cpu in platform {:?}", s);
5353
}
54-
if I86_PATTERN.is_match(&cpu) {
54+
if I86_PATTERN.is_match(cpu) {
5555
Some("x86")
5656
} else {
5757
Some(cpu)
@@ -60,7 +60,7 @@ impl Platform<'_> {
6060
None => panic!("empty cpu in platform {:?}", s),
6161
};
6262

63-
if parts.len() == 2 && DOTTED_PATTERN.is_match(&parts[1]) {
63+
if parts.len() == 2 && DOTTED_PATTERN.is_match(parts[1]) {
6464
return Platform {
6565
cpu,
6666
os: parts.pop_front().unwrap(),
@@ -121,7 +121,7 @@ impl Platform<'_> {
121121

122122
let mut double_locs = MSWIN_PATTERN.capture_locations();
123123

124-
if MSWIN_PATTERN.captures_read(&mut double_locs, &os).is_some() {
124+
if MSWIN_PATTERN.captures_read(&mut double_locs, os).is_some() {
125125
version = capture(&double_locs, os, 2);
126126
os = capture(&double_locs, os, 1).unwrap();
127127
if cpu.is_none() && os.ends_with("32") {
@@ -137,16 +137,13 @@ impl Platform<'_> {
137137

138138
os = "unknown";
139139

140-
return Platform { cpu, os, version };
140+
Platform { cpu, os, version }
141141
}
142142
}
143143

144144
impl std::fmt::Display for Platform<'_> {
145145
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
146-
match (&self.cpu, &self.os, &self.version) {
147-
(None, os, Some(version)) => return write!(f, "{}{}", os, version),
148-
_ => (),
149-
}
146+
if let (None, os, Some(version)) = (&self.cpu, &self.os, &self.version) { return write!(f, "{}{}", os, version) }
150147
if let Some(cpu) = self.cpu {
151148
write!(f, "{}-", cpu)?;
152149
}

src/user_agent.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::borrow::Cow;
2-
31
use crate::platform::Platform;
42
use regex::Regex;
53

@@ -120,7 +118,7 @@ pub fn parse(a: &str) -> Option<UserAgent> {
120118
}
121119
}
122120

123-
pub fn serialize_user_agent<S>(ua: &Cow<str>, serializer: S) -> Result<S::Ok, S::Error>
121+
pub fn serialize_user_agent<S>(ua: &str, serializer: S) -> Result<S::Ok, S::Error>
124122
where
125123
S: serde::Serializer,
126124
{

0 commit comments

Comments
 (0)