tool/shared: make clippy happy
- implements a trivial Default for Roots - implements a FromStr for OsRelease
This commit is contained in:
parent
fd188a0e32
commit
eba963b6f1
|
@ -80,6 +80,12 @@ impl Roots {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Roots {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::{collections::BTreeMap, str::FromStr};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
|
||||||
|
@ -34,14 +34,17 @@ impl OsRelease {
|
||||||
|
|
||||||
Ok(Self(map))
|
Ok(Self(map))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for OsRelease {
|
||||||
|
type Err = anyhow::Error;
|
||||||
/// Parse the string representation of a os-release file.
|
/// Parse the string representation of a os-release file.
|
||||||
///
|
///
|
||||||
/// **Beware before reusing this function!**
|
/// **Beware before reusing this function!**
|
||||||
///
|
///
|
||||||
/// This parser might not parse all valid os-release files correctly. It is only designed to
|
/// 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.
|
/// read the `VERSION` key from the os-release of a systemd-boot binary.
|
||||||
pub fn from_str(value: &str) -> Result<Self> {
|
fn from_str(value: &str) -> Result<Self> {
|
||||||
let mut map = BTreeMap::new();
|
let mut map = BTreeMap::new();
|
||||||
|
|
||||||
// All valid lines
|
// All valid lines
|
||||||
|
|
Loading…
Reference in New Issue