From f907d1ce0fe66f72188ccfe11d090752c5775d25 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 1 Mar 2021 09:10:07 +0200 Subject: fix: tidy up code based on suggestions from clippy --- src/cloudinit.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/cloudinit.rs b/src/cloudinit.rs index f1b56ce..2c521fd 100644 --- a/src/cloudinit.rs +++ b/src/cloudinit.rs @@ -129,17 +129,8 @@ impl Metadata { } fn cleanup_document(doc: &str) -> String { - let marker = "---\n"; - let doc = if doc.starts_with(marker) { - &doc[marker.len()..] - } else { - doc - }; - if doc.ends_with("\n") { - &doc[..doc.len() - 1] - } else { - doc - }; + let doc = doc.strip_prefix("---\n").or(Some(doc)).unwrap(); + let doc = doc.strip_suffix("\n").or(Some(doc)).unwrap(); doc.to_string() } @@ -160,7 +151,7 @@ impl Userdata { ssh_keys: Hostkeys::from(spec), runcmd: vec![ format!("python3 -c {}", quote(SCRIPT)), - format!("systemctl reload ssh"), + "systemctl reload ssh".to_string(), ], }) } -- cgit v1.2.1