Skip to content

Commit

Permalink
Improve builder::str::inner::Inner::into_string implementation
Browse files Browse the repository at this point in the history
Since `Inner::into_string` already takes ownership of `self` we can
avoid unnecessary copy and allocation by moving `Box<str>` and using
its implementation of `Into<String>`.
  • Loading branch information
aleksanderkrauze committed Feb 15, 2023
1 parent ad5d676 commit d6e7d46
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/builder/str.rs
Expand Up @@ -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(),
}
}
}
}
Expand Down

0 comments on commit d6e7d46

Please sign in to comment.