kanidmd_lib::prelude

Type Alias AttrString

pub type AttrString = SmartString<LazyCompact>;
Expand description

A convenience alias for a [LazyCompact] layout [SmartString].

Just pretend it’s a String!

Aliased Type§

struct AttrString { /* private fields */ }

Implementations

§

impl SmartString<LazyCompact>

pub const fn new_const() -> SmartString<LazyCompact>

Construct an empty string.

This is a const fn version of [SmartString::new]. It’s a temporary measure while we wait for trait bounds on type arguments to const fns to stabilise, and will be deprecated once this happens.

§

impl<Mode> SmartString<Mode>
where Mode: SmartStringMode,

pub fn new() -> SmartString<Mode>

Construct an empty string.

pub fn len(&self) -> usize

Return the length in bytes of the string.

Note that this may differ from the length in chars.

pub fn is_empty(&self) -> bool

Test whether the string is empty.

pub fn is_inline(&self) -> bool

Test whether the string is currently inlined.

pub fn as_str(&self) -> &str

Get a reference to the string as a string slice.

pub fn as_mut_str(&mut self) -> &mut str

Get a reference to the string as a mutable string slice.

pub fn capacity(&self) -> usize

Return the currently allocated capacity of the string.

Note that if this is a boxed string, it returns String::capacity(), but an inline string always returns [MAX_INLINE].

Note also that if a boxed string is converted into an inline string, its capacity is deallocated, and if the inline string is promoted to a boxed string in the future, it will be reallocated with a default capacity.

pub fn push(&mut self, ch: char)

Push a character to the end of the string.

pub fn push_str(&mut self, string: &str)

Copy a string slice onto the end of the string.

pub fn shrink_to_fit(&mut self)

Shrink the capacity of the string to fit its contents exactly.

This has no effect on inline strings, which always have a fixed capacity. Thus, it’s not safe to assume that [capacity()][SmartString::capacity] will equal [len()][SmartString::len] after calling this.

Calling this on a [LazyCompact] string that is currently heap allocated but is short enough to be inlined will deallocate the heap allocation and convert it to an inline string.

pub fn truncate(&mut self, new_len: usize)

Truncate the string to new_len bytes.

If new_len is larger than the string’s current length, this does nothing. If new_len isn’t on a UTF-8 character boundary, this method panics.

pub fn pop(&mut self) -> Option<char>

Pop a char off the end of the string.

pub fn remove(&mut self, index: usize) -> char

Remove a char from the string at the given index.

If the index doesn’t fall on a UTF-8 character boundary, this method panics.

pub fn insert(&mut self, index: usize, ch: char)

Insert a char into the string at the given index.

If the index doesn’t fall on a UTF-8 character boundary, this method panics.

pub fn insert_str(&mut self, index: usize, string: &str)

Insert a string slice into the string at the given index.

If the index doesn’t fall on a UTF-8 character boundary, this method panics.

pub fn split_off(&mut self, index: usize) -> SmartString<Mode>

Split the string into two at the given index.

Returns the content to the right of the index as a new string, and removes it from the original.

If the index doesn’t fall on a UTF-8 character boundary, this method panics.

pub fn clear(&mut self)

Clear the string.

This causes any memory reserved by the string to be immediately deallocated.

pub fn retain<F>(&mut self, f: F)
where F: FnMut(char) -> bool,

Filter out chars not matching a predicate.

pub fn drain<R>(&mut self, range: R) -> Drain<'_, Mode>
where R: RangeBounds<usize>,

Construct a draining iterator over a given range.

This removes the given range from the string, and returns an iterator over the removed chars.

pub fn replace_range<R>(&mut self, range: R, replace_with: &str)
where R: RangeBounds<usize>,

Replaces a range with the contents of a string slice.

Trait Implementations§

source§

impl From<EntryClass> for AttrString

source§

fn from(val: EntryClass) -> Self

Converts to this type from the input type.
§

impl<Mode> Add<&SmartString<Mode>> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = SmartString<Mode>

The resulting type after applying the + operator.
§

fn add( self, rhs: &SmartString<Mode>, ) -> <SmartString<Mode> as Add<&SmartString<Mode>>>::Output

Performs the + operation. Read more
§

impl<Mode> Add<&String> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = SmartString<Mode>

The resulting type after applying the + operator.
§

fn add(self, rhs: &String) -> <SmartString<Mode> as Add<&String>>::Output

Performs the + operation. Read more
§

impl<Mode> Add<&str> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = SmartString<Mode>

The resulting type after applying the + operator.
§

fn add(self, rhs: &str) -> <SmartString<Mode> as Add<&str>>::Output

Performs the + operation. Read more
§

impl<Mode> Add<String> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = SmartString<Mode>

The resulting type after applying the + operator.
§

fn add(self, rhs: String) -> <SmartString<Mode> as Add<String>>::Output

Performs the + operation. Read more
§

impl<Mode> Add for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = SmartString<Mode>

The resulting type after applying the + operator.
§

fn add(self, rhs: SmartString<Mode>) -> <SmartString<Mode> as Add>::Output

Performs the + operation. Read more
§

impl<Mode> AsMut<str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn as_mut(&mut self) -> &mut str

Converts this type into a mutable reference of the (usually inferred) input type.
§

impl<Mode> AsRef<[u8]> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<Mode> AsRef<str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<Mode> Borrow<str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
§

impl<Mode> BorrowMut<str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn borrow_mut(&mut self) -> &mut str

Mutably borrows from an owned value. Read more
§

impl<Mode> Clone for SmartString<Mode>
where Mode: SmartStringMode,

§

fn clone(&self) -> SmartString<Mode>

Clone a [SmartString].

If the string is inlined, this is a Copy operation. Otherwise, a string with the same capacity as the source is allocated.

1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<Mode> Debug for SmartString<Mode>
where Mode: SmartStringMode,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<Mode> Default for SmartString<Mode>
where Mode: SmartStringMode,

§

fn default() -> SmartString<Mode>

Returns the “default value” for a type. Read more
§

impl<Mode> DerefMut for SmartString<Mode>
where Mode: SmartStringMode,

§

fn deref_mut(&mut self) -> &mut <SmartString<Mode> as Deref>::Target

Mutably dereferences the value.
§

impl<'de, T> Deserialize<'de> for SmartString<T>
where T: SmartStringMode,

§

fn deserialize<D>( deserializer: D, ) -> Result<SmartString<T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<Mode> Display for SmartString<Mode>
where Mode: SmartStringMode,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<Mode> Drop for SmartString<Mode>
where Mode: SmartStringMode,

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl<'a, Mode> Extend<&'a SmartString<Mode>> for SmartString<Mode>
where Mode: SmartStringMode + 'a,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a SmartString<Mode>>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<'a, Mode> Extend<&'a String> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a String>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<'a, Mode> Extend<&'a char> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a char>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<'a, Mode> Extend<&'a str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a str>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<Mode> Extend<SmartString<Mode>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = SmartString<Mode>>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<Mode> Extend<String> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = String>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<Mode> Extend<char> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = char>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<Mode> From<&String> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from(string: &String) -> SmartString<Mode>

Converts to this type from the input type.
§

impl<Mode> From<&mut str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from(string: &mut str) -> SmartString<Mode>

Converts to this type from the input type.
§

impl<Mode> From<&str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from(string: &str) -> SmartString<Mode>

Converts to this type from the input type.
source§

impl From<Attribute> for SmartString<LazyCompact>

source§

fn from(val: Attribute) -> SmartString<LazyCompact>

Converts to this type from the input type.
§

impl<Mode> From<Box<str>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from(string: Box<str>) -> SmartString<Mode>

Converts to this type from the input type.
§

impl<Mode> From<Cow<'_, str>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from(string: Cow<'_, str>) -> SmartString<Mode>

Converts to this type from the input type.
§

impl<Mode> From<String> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from(string: String) -> SmartString<Mode>

Converts to this type from the input type.
§

impl<'a, Mode> FromIterator<&'a SmartString<Mode>> for SmartString<Mode>
where Mode: SmartStringMode + 'a,

§

fn from_iter<I>(iter: I) -> SmartString<Mode>
where I: IntoIterator<Item = &'a SmartString<Mode>>,

Creates a value from an iterator. Read more
§

impl<'a, Mode> FromIterator<&'a String> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from_iter<I>(iter: I) -> SmartString<Mode>
where I: IntoIterator<Item = &'a String>,

Creates a value from an iterator. Read more
§

impl<'a, Mode> FromIterator<&'a str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from_iter<I>(iter: I) -> SmartString<Mode>
where I: IntoIterator<Item = &'a str>,

Creates a value from an iterator. Read more
§

impl<Mode> FromIterator<SmartString<Mode>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from_iter<I>(iter: I) -> SmartString<Mode>
where I: IntoIterator<Item = SmartString<Mode>>,

Creates a value from an iterator. Read more
§

impl<Mode> FromIterator<String> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from_iter<I>(iter: I) -> SmartString<Mode>
where I: IntoIterator<Item = String>,

Creates a value from an iterator. Read more
§

impl<Mode> FromIterator<char> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn from_iter<I>(iter: I) -> SmartString<Mode>
where I: IntoIterator<Item = char>,

Creates a value from an iterator. Read more
§

impl<Mode> FromStr for SmartString<Mode>
where Mode: SmartStringMode,

§

type Err = Infallible

The associated error which can be returned from parsing.
§

fn from_str( s: &str, ) -> Result<SmartString<Mode>, <SmartString<Mode> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
§

impl<Mode> Hash for SmartString<Mode>
where Mode: SmartStringMode,

§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl<Mode> Index<Range<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = str

The returned type after indexing.
§

fn index( &self, index: Range<usize>, ) -> &<SmartString<Mode> as Index<Range<usize>>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<Mode> Index<RangeFrom<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = str

The returned type after indexing.
§

fn index( &self, index: RangeFrom<usize>, ) -> &<SmartString<Mode> as Index<RangeFrom<usize>>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<Mode> Index<RangeFull> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = str

The returned type after indexing.
§

fn index( &self, _index: RangeFull, ) -> &<SmartString<Mode> as Index<RangeFull>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<Mode> Index<RangeInclusive<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = str

The returned type after indexing.
§

fn index( &self, index: RangeInclusive<usize>, ) -> &<SmartString<Mode> as Index<RangeInclusive<usize>>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<Mode> Index<RangeTo<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = str

The returned type after indexing.
§

fn index( &self, index: RangeTo<usize>, ) -> &<SmartString<Mode> as Index<RangeTo<usize>>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<Mode> Index<RangeToInclusive<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

type Output = str

The returned type after indexing.
§

fn index( &self, index: RangeToInclusive<usize>, ) -> &<SmartString<Mode> as Index<RangeToInclusive<usize>>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<Mode> IndexMut<Range<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn index_mut( &mut self, index: Range<usize>, ) -> &mut <SmartString<Mode> as Index<Range<usize>>>::Output

Performs the mutable indexing (container[index]) operation. Read more
§

impl<Mode> IndexMut<RangeFrom<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn index_mut( &mut self, index: RangeFrom<usize>, ) -> &mut <SmartString<Mode> as Index<RangeFrom<usize>>>::Output

Performs the mutable indexing (container[index]) operation. Read more
§

impl<Mode> IndexMut<RangeFull> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn index_mut( &mut self, _index: RangeFull, ) -> &mut <SmartString<Mode> as Index<RangeFull>>::Output

Performs the mutable indexing (container[index]) operation. Read more
§

impl<Mode> IndexMut<RangeInclusive<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn index_mut( &mut self, index: RangeInclusive<usize>, ) -> &mut <SmartString<Mode> as Index<RangeInclusive<usize>>>::Output

Performs the mutable indexing (container[index]) operation. Read more
§

impl<Mode> IndexMut<RangeTo<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn index_mut( &mut self, index: RangeTo<usize>, ) -> &mut <SmartString<Mode> as Index<RangeTo<usize>>>::Output

Performs the mutable indexing (container[index]) operation. Read more
§

impl<Mode> IndexMut<RangeToInclusive<usize>> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn index_mut( &mut self, index: RangeToInclusive<usize>, ) -> &mut <SmartString<Mode> as Index<RangeToInclusive<usize>>>::Output

Performs the mutable indexing (container[index]) operation. Read more
§

impl<Mode> Ord for SmartString<Mode>
where Mode: SmartStringMode,

§

fn cmp(&self, other: &SmartString<Mode>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl<Mode> PartialEq<&str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn eq(&self, other: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<Mode> PartialEq<String> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn eq(&self, other: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<Mode> PartialEq<str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<Mode> PartialEq for SmartString<Mode>
where Mode: SmartStringMode,

§

fn eq(&self, other: &SmartString<Mode>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<Mode> PartialOrd<str> for SmartString<Mode>
where Mode: SmartStringMode,

§

fn partial_cmp(&self, other: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl<Mode> PartialOrd for SmartString<Mode>
where Mode: SmartStringMode,

§

fn partial_cmp(&self, other: &SmartString<Mode>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl<T> Serialize for SmartString<T>
where T: SmartStringMode,

§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl<Mode> Write for SmartString<Mode>
where Mode: SmartStringMode,

§

fn write_str(&mut self, string: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
§

impl<Mode> Deref for SmartString<Mode>
where Mode: SmartStringMode,

§

type Target = str

The resulting type after dereferencing.
§

fn deref(&self) -> &<SmartString<Mode> as Deref>::Target

Dereferences the value.
§

impl<Mode> Eq for SmartString<Mode>
where Mode: SmartStringMode,