From d6e7d4699f1f981143fbb4ebea0900c8e3ef5764 Mon Sep 17 00:00:00 2001 From: Aleksander Krauze Date: Wed, 15 Feb 2023 16:16:14 +0100 Subject: [PATCH] Improve builder::str::inner::Inner::into_string implementation Since `Inner::into_string` already takes ownership of `self` we can avoid unnecessary copy and allocation by moving `Box` and using its implementation of `Into`. --- src/builder/str.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/builder/str.rs b/src/builder/str.rs index c6689d31065..be69c3f6ee6 100644 --- a/src/builder/str.rs +++ b/src/builder/str.rs @@ -246,7 +246,10 @@ pub(crate) mod inner { } pub(crate) fn into_string(self) -> String { - self.as_str().to_owned() + match self { + Self::Static(s) => s.to_owned(), + Self::Owned(s) => s.into(), + } } } }