From 69c14e65f3d0aeec992c25bbc4843773d56341d6 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 2 Jul 2021 11:51:13 +0800 Subject: [PATCH] Add ImmutableString::new() to mirror String API. --- src/immutable_string.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/immutable_string.rs b/src/immutable_string.rs index 48c7e387..d6555698 100644 --- a/src/immutable_string.rs +++ b/src/immutable_string.rs @@ -522,6 +522,11 @@ impl PartialOrd for String { } impl ImmutableString { + /// Create a new [`ImmutableString`]. + #[inline(always)] + pub fn new() -> Self { + Self(SmartString::new().into()) + } /// Consume the [`ImmutableString`] and convert it into a [`String`]. /// If there are other references to the same string, a cloned copy is returned. #[inline(always)]