summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2026-11-10 21:38:27 +0100
committerPhilipp Gesang <philipp.gesang@eon.com>2026-11-10 13:33:14 +0100
commitca88af8a77b283b558554ac29ac1a74b925cee6a (patch)
tree84a882359adec57beeda45e775ab360303d4ead8
parente7476a58e05d7b6989a99ae7ed6d4ae63cf50e79 (diff)
clippy: auto-apply
-rw-r--r--src/lib.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index dd372c3..1c737ea 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -760,7 +760,7 @@ impl Scheme
pub fn base64(&self) -> io::Result<String>
{
let pal = Palette::try_from(self)?;
- Ok(base64::encode(&pal.0))
+ Ok(base64::encode(pal.0))
}
pub fn from_base64(b64: &str) -> io::Result<Self>
@@ -939,7 +939,7 @@ impl Palette
pal_idx = (pal_idx + 3) % PALETTE_BYTES;
}
}
- line.truncate(0);
+ line.clear();
}
Ok(Self(pal))
@@ -984,7 +984,7 @@ impl Palette
pub fn from_file(fname: &Path) -> io::Result<Self>
{
- let file = std::fs::File::open(&fname).map_err(|e| {
+ let file = std::fs::File::open(fname).map_err(|e| {
io::Error::other(format!(
"failed to open palette specification {}: {}",
fname.display(),
@@ -1023,7 +1023,7 @@ impl Palette
Ok(res)
}
- pub fn iter(&self) -> PaletteIterator { PaletteIterator::new(&self) }
+ pub fn iter(&self) -> PaletteIterator { PaletteIterator::new(self) }
/* [Palette::from_stdin] */
} /* [impl Palette] */
@@ -1057,7 +1057,7 @@ impl fmt::Debug for Palette
let r = self.0[i as usize];
let g = self.0[i as usize + 1];
let b = self.0[i as usize + 2];
- let col = Color::try_from((i / 3) as u8)
+ let col = Color::try_from(i / 3)
.map(|c| format!("{}", c))
.unwrap_or_else(|_| "??".into());
let _ = writeln!(f, "{} => 0x{:02.X}{:02.X}{:02.X}", col, r, g, b);
@@ -1125,14 +1125,14 @@ impl From<&[slint::Color]> for Palette
}
/** Convert palette to the default text format so it can be parsed as a scheme. */
-impl Into<String> for Palette
+impl From<Palette> for String
{
- fn into(self) -> String
+ fn from(val: Palette) -> Self
{
let mut acc = String::with_capacity(16 * 10);
for i in 0..PALETTE_SIZE {
let idx = i * 3;
- let (r, g, b) = (self.0[idx], self.0[idx + 1], self.0[idx + 2]);
+ let (r, g, b) = (val.0[idx], val.0[idx + 1], val.0[idx + 2]);
acc.push_str(&format!("{}#{:02.x}{:02.x}{:02.x}\n", i, r, g, b));
}
acc