From 7feb9f78e51c22ffa8c1cec5fed033e689949576 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 9 Sep 2022 10:05:22 +0300 Subject: chore: use unwrap_or instead of more complicated structure Sponsored-by: author --- src/cloudinit.rs | 4 ++-- src/spec.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cloudinit.rs b/src/cloudinit.rs index c748dd1..9d14538 100644 --- a/src/cloudinit.rs +++ b/src/cloudinit.rs @@ -175,8 +175,8 @@ impl Metadata { } fn cleanup_document(doc: &str) -> String { - let doc = doc.strip_prefix("---\n").or(Some(doc)).unwrap(); - let doc = doc.strip_suffix('\n').or(Some(doc)).unwrap(); + let doc = doc.strip_prefix("---\n").unwrap_or(doc); + let doc = doc.strip_suffix('\n').unwrap_or(doc); doc.to_string() } diff --git a/src/spec.rs b/src/spec.rs index 332bf94..5f5a28e 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -387,7 +387,7 @@ fn ssh_keys(filenames: &[PathBuf]) -> Result, SpecificationError> { let key = std::fs::read(&filename).map_err(|e| SpecificationError::SshKeyRead(filename, e))?; let key = String::from_utf8(key)?; - let key = key.strip_suffix('\n').or(Some(&key)).unwrap(); + let key = key.strip_suffix('\n').unwrap_or(&key); keys.push(key.to_string()); } Ok(keys) -- cgit v1.2.1