Skip to content

Commit

Permalink
Fix clippy lints up to Rust 1.82 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored Dec 3, 2024
1 parent e21313b commit c7b6eda
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
34 changes: 15 additions & 19 deletions src/directional_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,19 @@ impl DirectionalPosition {
/// Checks whether the value can be a horizontal position.
#[inline]
pub fn is_horizontal(&self) -> bool {
match self {
DirectionalPosition::Center
| DirectionalPosition::Left
| DirectionalPosition::Right => true,
_ => false,
}
matches!(
self,
DirectionalPosition::Center | DirectionalPosition::Left | DirectionalPosition::Right
)
}

/// Checks whether the value can be a vertical position.
#[inline]
pub fn is_vertical(&self) -> bool {
match self {
DirectionalPosition::Center
| DirectionalPosition::Top
| DirectionalPosition::Bottom => true,
_ => false,
}
matches!(
self,
DirectionalPosition::Center | DirectionalPosition::Top | DirectionalPosition::Bottom
)
}
}

Expand Down Expand Up @@ -79,21 +75,21 @@ impl Stream<'_> {

if self.starts_with(b"left") {
self.advance(4);
return Ok(DirectionalPosition::Left);
Ok(DirectionalPosition::Left)
} else if self.starts_with(b"right") {
self.advance(5);
return Ok(DirectionalPosition::Right);
Ok(DirectionalPosition::Right)
} else if self.starts_with(b"top") {
self.advance(3);
return Ok(DirectionalPosition::Top);
Ok(DirectionalPosition::Top)
} else if self.starts_with(b"bottom") {
self.advance(6);
return Ok(DirectionalPosition::Bottom);
Ok(DirectionalPosition::Bottom)
} else if self.starts_with(b"center") {
self.advance(6);
return Ok(DirectionalPosition::Center);
Ok(DirectionalPosition::Center)
} else {
return Err(Error::InvalidString(
Err(Error::InvalidString(
vec![
self.slice_tail().to_string(),
"left".to_string(),
Expand All @@ -103,7 +99,7 @@ impl Stream<'_> {
"center".to_string(),
],
self.calc_char_pos(),
));
))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl<'a> FontShorthand<'a> {
/// an owned value as a return type.
///
/// [font]: https://www.w3.org/TR/css-fonts-3/#font-prop
#[allow(clippy::should_implement_trait)] // We aren't changing public API yet.
pub fn from_str(text: &'a str) -> Result<Self, Error> {
let mut stream = Stream::from(text);
stream.skip_spaces();
Expand Down
4 changes: 2 additions & 2 deletions src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,13 @@ mod tests {
#[test]
fn parse_err_4() {
let mut ts = TransformListParser::from(" ");
assert_eq!(ts.next().is_none(), true);
assert!(ts.next().is_none());
}

#[test]
fn parse_err_5() {
let mut ts = TransformListParser::from("\x01");
assert_eq!(ts.next().unwrap().is_err(), true);
assert!(ts.next().unwrap().is_err());
}

test_err!(parse_err_6, "rect()", "unexpected data at position 1");
Expand Down

0 comments on commit c7b6eda

Please sign in to comment.