From b7526ec069fb0d60acd32de909713a0e73c09f37 Mon Sep 17 00:00:00 2001 From: Henry Hrvoje Tonkovac Date: Mon, 8 Jun 2026 15:22:03 +0200 Subject: [PATCH] option_parser: trim qualified paths Import std::fmt and std::result instead of spelling the full paths at every use site. Signed-off-by: Henry Hrvoje Tonkovac Assisted-by: Claude:Opus-4.8 --- option_parser/src/lib.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/option_parser/src/lib.rs b/option_parser/src/lib.rs index cd7bbd488..a81caca8b 100644 --- a/option_parser/src/lib.rs +++ b/option_parser/src/lib.rs @@ -27,8 +27,9 @@ //! ``` use std::collections::HashMap; -use std::fmt::{Display, Write}; +use std::fmt::{self, Display, Write}; use std::num::ParseIntError; +use std::result; use std::str::FromStr; use thiserror::Error; @@ -82,7 +83,7 @@ pub enum OptionParserError { #[error("invalid value: {0}")] InvalidValue(String), } -type OptionParserResult = std::result::Result; +type OptionParserResult = result::Result; fn split_commas(s: &str) -> OptionParserResult> { let mut list: Vec = Vec::new(); @@ -302,7 +303,7 @@ pub enum ToggleParseError { impl Parseable for Toggle { type Err = ToggleParseError; - fn from_str(s: &str) -> std::result::Result { + fn from_str(s: &str) -> result::Result { match s.to_lowercase().as_str() { "" => Ok(Toggle(false)), "on" => Ok(Toggle(true)), @@ -329,7 +330,7 @@ pub enum ByteSizedParseError { impl FromStr for ByteSized { type Err = ByteSizedParseError; - fn from_str(s: &str) -> std::result::Result { + fn from_str(s: &str) -> result::Result { Ok(ByteSized({ let s = s.trim(); let shift = if s.ends_with('K') { @@ -356,7 +357,7 @@ impl FromStr for ByteSized { pub struct IntegerList(pub Vec); impl Display for IntegerList { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_char('[')?; let mut iter = self.0.iter(); if let Some(first) = iter.next() { @@ -379,7 +380,7 @@ pub enum IntegerListParseError { impl Parseable for IntegerList { type Err = IntegerListParseError; - fn from_str(s: &str) -> std::result::Result { + fn from_str(s: &str) -> result::Result { let mut integer_list = Vec::new(); let ranges_list: Vec<&str> = s .trim() @@ -486,7 +487,7 @@ pub enum TupleError { impl Parseable for Tuple { type Err = TupleError; - fn from_str(s: &str) -> std::result::Result { + fn from_str(s: &str) -> result::Result { let mut list: Vec<(S, T)> = Vec::new(); let body = s .trim() @@ -562,7 +563,7 @@ where T: FromStr + Sized, { type Err = ::Err; - fn from_str(s: &str) -> std::result::Result { + fn from_str(s: &str) -> result::Result { dequote(s).parse() } } @@ -570,7 +571,7 @@ where impl Parseable for StringList { type Err = StringListParseError; - fn from_str(s: &str) -> std::result::Result { + fn from_str(s: &str) -> result::Result { let string_list: Vec = split_commas(s.trim().trim_matches(|c| c == '[' || c == ']')) .map_err(|_| StringListParseError::InvalidValue(s.to_owned()))?