Add no_smartstring to disable using SmartString.

This commit is contained in:
Stephen Chung
2021-05-08 22:59:33 +08:00
parent 2c0215ea3f
commit d230f448c0
11 changed files with 45 additions and 49 deletions

View File

@@ -140,11 +140,11 @@ pub use utils::ImmutableString;
/// An identifier in Rhai. [`SmartString`](https://crates.io/crates/smartstring) is used because most
/// identifiers are ASCII and short, fewer than 23 characters, so they can be stored inline.
#[cfg(not(feature = "no_smartstring_for_identifier"))]
#[cfg(not(feature = "no_smartstring"))]
pub type Identifier = SmartString;
/// An identifier in Rhai.
#[cfg(feature = "no_smartstring_for_identifier")]
#[cfg(feature = "no_smartstring")]
pub type Identifier = ImmutableString;
/// A trait to enable registering Rust functions.
@@ -306,9 +306,14 @@ type StaticVec<T> = smallvec::SmallVec<[T; 4]>;
pub type StaticVec<T> = smallvec::SmallVec<[T; 4]>;
#[cfg(not(feature = "internals"))]
#[cfg(not(feature = "no_smartstring"))]
pub(crate) type SmartString = smartstring::SmartString<smartstring::Compact>;
#[cfg(feature = "no_smartstring")]
pub(crate) type SmartString = String;
#[cfg(feature = "internals")]
#[cfg(not(feature = "no_smartstring"))]
pub type SmartString = smartstring::SmartString<smartstring::Compact>;
// Compiler guards against mutually-exclusive feature flags