clippy: use unwrap_or_default

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2021-01-19 11:31:37 +01:00
parent a375df6f4c
commit 17c7b46a69
4 changed files with 5 additions and 5 deletions

View File

@ -749,7 +749,7 @@ async fn generate_host_stats(save: bool) {
match datastore::config() {
Ok((config, _)) => {
let datastore_list: Vec<datastore::DataStoreConfig> =
config.convert_to_typed_array("datastore").unwrap_or(Vec::new());
config.convert_to_typed_array("datastore").unwrap_or_default();
for config in datastore_list {

View File

@ -515,7 +515,7 @@ pub fn config() -> Result<(NetworkConfig, [u8;32]), Error> {
Some(content) => content,
None => {
let content = proxmox::tools::fs::file_get_optional_contents(NETWORK_INTERFACES_FILENAME)?;
content.unwrap_or(Vec::new())
content.unwrap_or_default()
}
};

View File

@ -215,12 +215,12 @@ impl <R: BufRead> NetworkParser<R> {
Token::Comment => {
let comment = self.eat(Token::Comment)?;
if !address_family_v4 && address_family_v6 {
let mut comments = interface.comments6.take().unwrap_or(String::new());
let mut comments = interface.comments6.take().unwrap_or_default();
if !comments.is_empty() { comments.push('\n'); }
comments.push_str(&comment);
interface.comments6 = Some(comments);
} else {
let mut comments = interface.comments.take().unwrap_or(String::new());
let mut comments = interface.comments.take().unwrap_or_default();
if !comments.is_empty() { comments.push('\n'); }
comments.push_str(&comment);
interface.comments = Some(comments);

View File

@ -434,7 +434,7 @@ pub fn lookup_datastore_notify_settings(
None => lookup_user_email(Userid::root_userid()),
};
let notify_str = config.notify.unwrap_or(String::new());
let notify_str = config.notify.unwrap_or_default();
if let Ok(value) = parse_property_string(&notify_str, &DatastoreNotify::API_SCHEMA) {
if let Ok(notify) = serde_json::from_value(value) {