From eba963b6f1b51f9a0d8cb45fc7d62853fd00fbf4 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Thu, 14 Sep 2023 11:12:34 +0200 Subject: [PATCH] tool/shared: make clippy happy - implements a trivial Default for Roots - implements a FromStr for OsRelease --- rust/tool/shared/src/gc.rs | 6 ++++++ rust/tool/shared/src/os_release.rs | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/rust/tool/shared/src/gc.rs b/rust/tool/shared/src/gc.rs index 85e4398..2dd66b6 100644 --- a/rust/tool/shared/src/gc.rs +++ b/rust/tool/shared/src/gc.rs @@ -80,6 +80,12 @@ impl Roots { } } +impl Default for Roots { + fn default() -> Self { + Self::new() + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/rust/tool/shared/src/os_release.rs b/rust/tool/shared/src/os_release.rs index 42e75c1..cdee3dc 100644 --- a/rust/tool/shared/src/os_release.rs +++ b/rust/tool/shared/src/os_release.rs @@ -1,5 +1,5 @@ -use std::collections::BTreeMap; use std::fmt; +use std::{collections::BTreeMap, str::FromStr}; use anyhow::{Context, Result}; @@ -34,14 +34,17 @@ impl OsRelease { Ok(Self(map)) } +} +impl FromStr for OsRelease { + type Err = anyhow::Error; /// Parse the string representation of a os-release file. /// /// **Beware before reusing this function!** /// /// This parser might not parse all valid os-release files correctly. It is only designed to /// read the `VERSION` key from the os-release of a systemd-boot binary. - pub fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { let mut map = BTreeMap::new(); // All valid lines