[clippy] api: mostly noise reduction

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-08-22 09:45:39 +02:00
parent 09d84f6634
commit ec1448cd29
3 changed files with 7 additions and 3 deletions

View File

@ -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 /// 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 /// usually overrides it. Ideally we can hyperlink the parameter to the type information in the
/// generated documentation. /// generated documentation.
@ -79,7 +81,7 @@ pub struct TypeInfo {
pub name: &'static str, pub name: &'static str,
pub description: &'static str, pub description: &'static str,
pub complete_fn: Option<CompleteFn>, 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 { impl TypeInfo {

View File

@ -110,6 +110,7 @@ pub struct SubCommands {
commands: HashMap<&'static str, Command>, commands: HashMap<&'static str, Command>,
} }
#[allow(clippy::new_without_default)]
impl SubCommands { impl SubCommands {
/// Create a new empty SubCommands hash. /// Create a new empty SubCommands hash.
pub fn new() -> Self { pub fn new() -> Self {
@ -246,6 +247,7 @@ impl Method {
} }
} }
#[allow(clippy::enum_variant_names)]
enum Arg<'a> { enum Arg<'a> {
Positional(&'a str), Positional(&'a str),
Opt(&'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> { fn parse_cli(name: &str, value: Option<&str>) -> Result<Value, Error> {
Ok(serde_json::Value::Array( Ok(serde_json::Value::Array(
value value

View File

@ -103,7 +103,7 @@ where
.get_or_insert_with(serde_json::Map::new) .get_or_insert_with(serde_json::Map::new)
.insert( .insert(
param_name.to_string(), param_name.to_string(),
Value::String(matched_wildcard.unwrap_or(String::new())), Value::String(matched_wildcard.unwrap_or_else(String::new)),
); );
} }