Simplify unset_empty()

This commit is contained in:
link2xt
2023-01-31 23:58:38 +00:00
parent b62c61329a
commit e318f5c697

View File

@@ -1,6 +1,5 @@
//! # Login parameters. //! # Login parameters.
use std::borrow::Cow;
use std::fmt; use std::fmt;
use anyhow::{ensure, Result}; use anyhow::{ensure, Result};
@@ -298,12 +297,11 @@ impl fmt::Display for LoginParam {
} }
} }
#[allow(clippy::ptr_arg)] fn unset_empty(s: &str) -> &str {
fn unset_empty(s: &String) -> Cow<String> {
if s.is_empty() { if s.is_empty() {
Cow::Owned("unset".to_string()) "unset"
} else { } else {
Cow::Borrowed(s) s
} }
} }