summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2026-11-10 21:34:21 +0100
committerPhilipp Gesang <philipp.gesang@eon.com>2026-11-10 13:33:14 +0100
commit1245569525671a227cca072ac850db0b3d5bca1d (patch)
tree50e7c0ca0e729084d90501da6e766a6bd7b8a2e4 /src
parent01015817ce3fee8a7b0142d50e956d03479ea97e (diff)
clippy: switch to std::io::Error::other()
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs90
1 files changed, 35 insertions, 55 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6db82e2..dd372c3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -295,13 +295,10 @@ impl TryFrom<u8> for KbLeds
if val <= 0b111 {
Ok(Self(val))
} else {
- Err(io::Error::new(
- io::ErrorKind::Other,
- format!(
- "invalid raw led value: {:#b}; must not exceed 3 b",
- val
- ),
- ))
+ Err(io::Error::other(format!(
+ "invalid raw led value: {:#b}; must not exceed 3 b",
+ val
+ )))
}
}
}
@@ -583,11 +580,7 @@ impl TryFrom<u8> for Color
0x0e => Ok(Color::Cyan(true)),
0x0f => Ok(Color::White(true)),
- _ =>
- Err(io::Error::new(
- io::ErrorKind::Other,
- format!("invalid color value: {}", val),
- )),
+ _ => Err(io::Error::other(format!("invalid color value: {}", val))),
}
}
} /* [impl TryFrom<u8> for Color] */
@@ -719,10 +712,7 @@ impl TryFrom<&str> for Builtin
}
}
- Err(io::Error::new(
- io::ErrorKind::Other,
- format!("no such builtin scheme: {}", name),
- ))
+ Err(io::Error::other(format!("no such builtin scheme: {}", name)))
}
}
@@ -777,10 +767,10 @@ impl Scheme
{
base64::decode(b64.as_bytes())
.map_err(|e| {
- io::Error::new(
- io::ErrorKind::Other,
- format!("failed to decode input as base64: {}", e),
- )
+ io::Error::other(format!(
+ "failed to decode input as base64: {}",
+ e
+ ))
})
.and_then(|b| Palette::from_bytes(&b))
.map(Self::from)
@@ -829,10 +819,10 @@ fn nibble_of_char(chr: u8) -> io::Result<u8>
b'a'..=b'f' => Ok(chr - b'a' + 10),
b'A'..=b'F' => Ok(chr - b'A' + 10),
_ =>
- Err(io::Error::new(
- io::ErrorKind::Other,
- format!("junk input ‘{}’ does not represent a hex digit", chr,),
- )),
+ Err(io::Error::other(format!(
+ "junk input ‘{}’ does not represent a hex digit",
+ chr,
+ ))),
}
}
@@ -932,10 +922,10 @@ impl Palette
let off = off + 1;
if off > len - 6 {
/* no room left for color definition after '#' char */
- return Err(io::Error::new(
- io::ErrorKind::Other,
- format!("invalid color definition: {}", line),
- ));
+ return Err(io::Error::other(format!(
+ "invalid color definition: {}",
+ line
+ )));
}
col.copy_from_slice(
@@ -995,14 +985,11 @@ impl Palette
pub fn from_file(fname: &Path) -> io::Result<Self>
{
let file = std::fs::File::open(&fname).map_err(|e| {
- io::Error::new(
- io::ErrorKind::Other,
- format!(
- "failed to open palette specification {}: {}",
- fname.display(),
- e
- ),
- )
+ io::Error::other(format!(
+ "failed to open palette specification {}: {}",
+ fname.display(),
+ e
+ ))
})?;
let mut reader = std::io::BufReader::new(file);
@@ -1023,14 +1010,11 @@ impl Palette
fn from_bytes(b: &[u8]) -> io::Result<Self>
{
if b.len() != PALETTE_SIZE * 3 {
- return Err(io::Error::new(
- io::ErrorKind::Other,
- format!(
- "expected {} B of data, got {}",
- PALETTE_SIZE * 3,
- b.len()
- ),
- ));
+ return Err(io::Error::other(format!(
+ "expected {} B of data, got {}",
+ PALETTE_SIZE * 3,
+ b.len()
+ )));
}
let mut res = Self::new();
@@ -1240,13 +1224,10 @@ impl Console
/* Sanity check. */
if ioctl::kdgkbtype(&fd)? != ioctl::KB_101 {
- return Err(io::Error::new(
- io::ErrorKind::Other,
- format!(
- "console {} exhibiting weird behavior; bailing out",
- fd
- ),
- ));
+ return Err(io::Error::other(format!(
+ "console {} exhibiting weird behavior; bailing out",
+ fd
+ )));
}
Ok(fd)
@@ -1272,10 +1253,9 @@ impl Console
}
}
- Err(io::Error::new(
- io::ErrorKind::Other,
- String::from("could not retrieve fd for any of the search paths"),
- ))
+ Err(io::Error::other(String::from(
+ "could not retrieve fd for any of the search paths",
+ )))
}
fn write(&self, buf: &[u8]) -> io::Result<()>