summaryrefslogtreecommitdiff
path: root/src/geom
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-12-30 11:37:11 +0100
committerLaurenz <laurmaedje@gmail.com>2021-12-30 12:00:12 +0100
commitf5dcb84e36a38182218c7f907b861b12d2bd2c1c (patch)
tree1fce04fb53d2ad5b61f5f3151e43d80e2684e579 /src/geom
parentfef55025177ea4f248e61b68fab365bfbc0e47fb (diff)
Make clippy a bit happier
Diffstat (limited to 'src/geom')
-rw-r--r--src/geom/paint.rs18
-rw-r--r--src/geom/scalar.rs2
2 files changed, 10 insertions, 10 deletions
diff --git a/src/geom/paint.rs b/src/geom/paint.rs
index 66bfb17c..0eba9f2f 100644
--- a/src/geom/paint.rs
+++ b/src/geom/paint.rs
@@ -72,7 +72,7 @@ impl RgbaColor {
}
impl FromStr for RgbaColor {
- type Err = ParseRgbaError;
+ type Err = RgbaError;
/// Constructs a new color from hex strings like the following:
/// - `#aef` (shorthand, with leading hashtag),
@@ -83,7 +83,7 @@ impl FromStr for RgbaColor {
fn from_str(hex_str: &str) -> Result<Self, Self::Err> {
let hex_str = hex_str.strip_prefix('#').unwrap_or(hex_str);
if !hex_str.is_ascii() {
- return Err(ParseRgbaError);
+ return Err(RgbaError);
}
let len = hex_str.len();
@@ -92,7 +92,7 @@ impl FromStr for RgbaColor {
let alpha = len == 4 || len == 8;
if !long && !short {
- return Err(ParseRgbaError);
+ return Err(RgbaError);
}
let mut values: [u8; 4] = [255; 4];
@@ -102,7 +102,7 @@ impl FromStr for RgbaColor {
let pos = elem * item_len;
let item = &hex_str[pos .. (pos + item_len)];
- values[elem] = u8::from_str_radix(item, 16).map_err(|_| ParseRgbaError)?;
+ values[elem] = u8::from_str_radix(item, 16).map_err(|_| RgbaError)?;
if short {
// Duplicate number for shorthand notation, i.e. `a` -> `aa`
@@ -134,15 +134,15 @@ impl Debug for RgbaColor {
/// The error when parsing an [`RgbaColor`] from a string fails.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
-pub struct ParseRgbaError;
+pub struct RgbaError;
-impl Display for ParseRgbaError {
+impl Display for RgbaError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- f.pad("invalid color")
+ f.pad("invalid hex string")
}
}
-impl std::error::Error for ParseRgbaError {}
+impl std::error::Error for RgbaError {}
#[cfg(test)]
mod tests {
@@ -166,7 +166,7 @@ mod tests {
fn test_parse_invalid_colors() {
#[track_caller]
fn test(hex: &str) {
- assert_eq!(RgbaColor::from_str(hex), Err(ParseRgbaError));
+ assert_eq!(RgbaColor::from_str(hex), Err(RgbaError));
}
test("12345");
diff --git a/src/geom/scalar.rs b/src/geom/scalar.rs
index 066246a9..948ea7ec 100644
--- a/src/geom/scalar.rs
+++ b/src/geom/scalar.rs
@@ -27,7 +27,7 @@ impl Debug for Scalar {
impl Ord for Scalar {
fn cmp(&self, other: &Self) -> Ordering {
- self.partial_cmp(&other).expect("float is NaN")
+ self.partial_cmp(other).expect("float is NaN")
}
}