diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-09-09 10:05:22 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-09-09 10:05:22 +0300 |
commit | 7feb9f78e51c22ffa8c1cec5fed033e689949576 (patch) | |
tree | 36bce045f130b6f1cf1f4b0004a4f69ddc92a821 | |
parent | bafcd4242edcac67039b0c12fa33f27445bee03d (diff) | |
download | vmadm-7feb9f78e51c22ffa8c1cec5fed033e689949576.tar.gz |
chore: use unwrap_or instead of more complicated structure
Sponsored-by: author
-rw-r--r-- | src/cloudinit.rs | 4 | ||||
-rw-r--r-- | 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<Vec<String>, 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) |