[][src]Struct smol_str::SmolStr

pub struct SmolStr(_);

A SmolStr is a string type that has the following properties:

  • size_of::<SmolStr>() == size_of::<String>()
  • Clone is O(1)
  • Strings are stack-allocated if they are:
    • Up to 22 bytes long
    • Longer than 22 bytes, but substrings of WS (see below). Such strings consist solely of consecutive newlines, followed by consecutive spaces
  • If a string does not satisfy the aforementioned conditions, it is heap-allocated

Unlike String, however, SmolStr is immutable. The primary use case for SmolStr is a good enough default storage for tokens of typical programming languages. Strings consisting of a series of newlines, followed by a series of whitespace are a typical pattern in computer programs because of indentation. Note that a specialized interner might be a better solution for some use cases.

Methods

impl SmolStr
[src]

Trait Implementations

impl PartialEq<SmolStr> for SmolStr
[src]

This method tests for !=.

impl PartialEq<str> for SmolStr
[src]

This method tests for !=.

impl PartialEq<SmolStr> for str
[src]

This method tests for !=.

impl<'a> PartialEq<&'a str> for SmolStr
[src]

This method tests for !=.

impl<'a> PartialEq<SmolStr> for &'a str
[src]

This method tests for !=.

impl PartialEq<String> for SmolStr
[src]

This method tests for !=.

impl PartialEq<SmolStr> for String
[src]

This method tests for !=.

impl<'a> PartialEq<&'a String> for SmolStr
[src]

This method tests for !=.

impl<'a> PartialEq<SmolStr> for &'a String
[src]

This method tests for !=.

impl<T> From<T> for SmolStr where
    T: Into<String> + AsRef<str>, 
[src]

impl From<SmolStr> for String
[src]

impl Clone for SmolStr
[src]

Performs copy-assignment from source. Read more

impl Eq for SmolStr
[src]

impl Default for SmolStr
[src]

impl Display for SmolStr
[src]

impl Debug for SmolStr
[src]

impl Deref for SmolStr
[src]

The resulting type after dereferencing.

impl Hash for SmolStr
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl Send for SmolStr

impl Sync for SmolStr

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]