Add ImmutableString::new() to mirror String API.

This commit is contained in:
Stephen Chung 2021-07-02 11:51:13 +08:00
parent 88bfe64e35
commit 69c14e65f3

View File

@ -522,6 +522,11 @@ impl PartialOrd<ImmutableString> 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)]