mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-08 04:51:37 +00:00
[clippy] api: mostly noise reduction
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
09d84f6634
commit
ec1448cd29
@ -72,6 +72,8 @@ impl Parameter {
|
||||
}
|
||||
}
|
||||
|
||||
pub type ParseCliFn = fn(name: &str, value: Option<&str>) -> Result<Value, Error>;
|
||||
|
||||
/// Bare type info. Types themselves should also have a description, even if a method's parameter
|
||||
/// usually overrides it. Ideally we can hyperlink the parameter to the type information in the
|
||||
/// generated documentation.
|
||||
@ -79,7 +81,7 @@ pub struct TypeInfo {
|
||||
pub name: &'static str,
|
||||
pub description: &'static str,
|
||||
pub complete_fn: Option<CompleteFn>,
|
||||
pub parse_cli: Option<fn(name: &str, value: Option<&str>) -> Result<Value, Error>>,
|
||||
pub parse_cli: Option<ParseCliFn>,
|
||||
}
|
||||
|
||||
impl TypeInfo {
|
||||
|
@ -110,6 +110,7 @@ pub struct SubCommands {
|
||||
commands: HashMap<&'static str, Command>,
|
||||
}
|
||||
|
||||
#[allow(clippy::new_without_default)]
|
||||
impl SubCommands {
|
||||
/// Create a new empty SubCommands hash.
|
||||
pub fn new() -> Self {
|
||||
@ -246,6 +247,7 @@ impl Method {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum Arg<'a> {
|
||||
Positional(&'a str),
|
||||
Opt(&'a str),
|
||||
@ -389,7 +391,7 @@ impl ParseCli for String {
|
||||
}
|
||||
}
|
||||
|
||||
impl ParseCli for HashSet<String> {
|
||||
impl<S: std::hash::BuildHasher> ParseCli for HashSet<String, S> {
|
||||
fn parse_cli(name: &str, value: Option<&str>) -> Result<Value, Error> {
|
||||
Ok(serde_json::Value::Array(
|
||||
value
|
||||
|
@ -103,7 +103,7 @@ where
|
||||
.get_or_insert_with(serde_json::Map::new)
|
||||
.insert(
|
||||
param_name.to_string(),
|
||||
Value::String(matched_wildcard.unwrap_or(String::new())),
|
||||
Value::String(matched_wildcard.unwrap_or_else(String::new)),
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user