From 6d55b3c309f98b7c9998c5b2419dda4ddc7bc03a Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Fri, 12 Mar 2021 02:55:40 +1000 Subject: [PATCH] removed an unecessary allocation you know what they say, premature optimisation is the best optimisation --- rustfmt.toml | 4 ++++ src/findings.rs | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..8e5edff --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,4 @@ +max_width = 120 +hard_tabs = true +tab_spaces = 2 +newline_style = "Unix" \ No newline at end of file diff --git a/src/findings.rs b/src/findings.rs index 2fbbee1..0190569 100644 --- a/src/findings.rs +++ b/src/findings.rs @@ -1,7 +1,6 @@ use std::path::PathBuf; use mime_guess::Mime; -use smartstring::alias::String; use crate::inspectors::mime_extension_lookup; @@ -16,7 +15,7 @@ pub struct Findings { } impl Findings { - pub fn recommended_extension(&self) -> Option { - mime_extension_lookup(self.mime.clone()).map(|extensions| extensions[0].to_owned()) + pub fn recommended_extension(&self) -> Option<&str> { + mime_extension_lookup(self.mime.clone()).map(|extensions| &*extensions[0]) } }