mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-31 01:30:00 +00:00
Using .map() instead.
This commit is contained in:
parent
8009251bf2
commit
a2f4907209
1 changed files with 1 additions and 10 deletions
|
@ -176,16 +176,7 @@ pub fn clean_url_params(mut url: Url) -> Url {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clean_optional_text(text: &Option<String>) -> Option<String> {
|
pub fn clean_optional_text(text: &Option<String>) -> Option<String> {
|
||||||
if let Some(text) = text {
|
text.as_ref().map(|t| t.trim().to_string())
|
||||||
let trimmed = text.trim();
|
|
||||||
if trimmed.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(trimmed.to_owned())
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue