refactor: apply clippy auto-fixes (162 warnings resolved)
- Fix needless borrows and references - Collapse nested if statements - Replace manual strip_prefix with str::strip_prefix() - Remove redundant closures in map/unwrap_or_else - Use Iterator::next_back() instead of rev().next() - Simplify map_or patterns - Use std::io::Error::other() instead of new(ErrorKind::Other, ..) - Use div_ceil() instead of manual ceiling division - Consolidate format! string arguments - Various other idiomatic Rust improvements 39 files changed, 220 insertions(+), 320 deletions(-)
This commit is contained in:
@@ -380,8 +380,8 @@ impl ContactUseCase for ContactStorageAdapter {
|
||||
} else if trimmed.starts_with("NOTE:") {
|
||||
notes = Some(trimmed[5..].trim().to_string());
|
||||
} else if trimmed.starts_with("EMAIL") {
|
||||
if let Some(value) = trimmed.split(':').nth(1) {
|
||||
if !value.is_empty() {
|
||||
if let Some(value) = trimmed.split(':').nth(1)
|
||||
&& !value.is_empty() {
|
||||
let email_type = if trimmed.contains("TYPE=HOME") { "home" }
|
||||
else if trimmed.contains("TYPE=WORK") { "work" }
|
||||
else { "other" };
|
||||
@@ -391,10 +391,9 @@ impl ContactUseCase for ContactStorageAdapter {
|
||||
is_primary: emails.is_empty(),
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if trimmed.starts_with("TEL") {
|
||||
if let Some(value) = trimmed.split(':').nth(1) {
|
||||
if !value.is_empty() {
|
||||
} else if trimmed.starts_with("TEL")
|
||||
&& let Some(value) = trimmed.split(':').nth(1)
|
||||
&& !value.is_empty() {
|
||||
let phone_type = if trimmed.contains("TYPE=CELL") || trimmed.contains("TYPE=MOBILE") { "mobile" }
|
||||
else if trimmed.contains("TYPE=HOME") { "home" }
|
||||
else if trimmed.contains("TYPE=WORK") { "work" }
|
||||
@@ -405,8 +404,6 @@ impl ContactUseCase for ContactStorageAdapter {
|
||||
is_primary: phones.is_empty(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let contact_uid = uid.unwrap_or_else(|| format!("{}@oxicloud", Uuid::new_v4()));
|
||||
|
||||
Reference in New Issue
Block a user