[−][src]Enum dynstr::DynamicString
An immutable string representation with efficient memory management for heavy string manipulations.
Variants
Represents an empty string.
SingleOneByteChar(u8)
The string consists of a single one-byte (u8) character.
SingleTwoByteChar(u16)
The string consists of a single two-byte (u16) character.
Sequence of one-byte characters (such as an ASCII text), the sequence must be non-empty.
Sequence of two-byte (utf-16) characters, the sequence must be non-empty.
A view over another DynamicString limited to the provided range.
Fields of SlicedString
The result of concatenating two DynamicStrings.
Fields of ConsString
first: Box<DynamicString>
second: Box<DynamicString>
Implementations
impl DynamicString
[src]
pub fn slice(&self, start: usize, length: usize) -> Self
[src]
Extracts a section of a string and returns it as a new string, without modifying the original string.
pub fn append<T: Into<DynamicString>>(&self, other: T) -> Self
[src]
Concatenate the current string with another string, returns the result.
use dynstr::DynamicString; let str = DynamicString::new("hello"); assert_eq!(str.append(" world"), DynamicString::new("hello world"));
pub fn index_of<T: Into<DynamicString>>(&self, pattern: T) -> Option<usize>
[src]
Return the index of the first occurrence of the specified value in the current string.
use dynstr::DynamicString; let str = DynamicString::new("Hello world"); assert_eq!(str.index_of("world"), Some(6)); assert_eq!(str.index_of("world!"), None);
pub fn split<T: Into<DynamicString>>(
&self,
separator: T,
limit: Option<usize>
) -> Vec<DynamicString>
[src]
&self,
separator: T,
limit: Option<usize>
) -> Vec<DynamicString>
Divides a String into an ordered list of substrings, puts these substrings into a vector,
and returns the vector. The division is done by searching for a pattern; where the pattern
is provided as the first parameter in the method's call.
This method tries to follow the JavaScript's String.split method in edge cases.
use dynstr::DynamicString; let str = DynamicString::new("Hello world"); assert_eq!(DynamicString::new("Jack,Joe,John").split(",", None), vec!["Jack", "Joe", "John"]); assert_eq!(DynamicString::new("Jack,Joe,John").split(",", Some(1)), vec!["Jack"]); // edge cases: assert!(DynamicString::new("").split("", None).is_empty()); assert_eq!(DynamicString::new("ABC").split("", None), vec!["A", "B", "C"]); assert_eq!(DynamicString::new("").split("ABC", None), vec![""]);
pub fn starts_with<T: Into<DynamicString>>(&self, other: T) -> bool
[src]
Determines whether a string begins with the characters of a specified string, returning true or false as appropriate.
impl DynamicString
[src]
pub fn new(data: &str) -> Self
[src]
pub fn empty() -> Self
[src]
Returns a new empty string.
pub fn len(&self) -> usize
[src]
Returns length of the string.
pub fn has_one_byte_char(&self) -> bool
[src]
Returns true if this string only contains one-byte characters.
pub fn flatten(self) -> Self
[src]
Flatten this DynamicString.
pub fn iter(&self) -> DynamicStringIteratorⓘNotable traits for DynamicStringIterator
impl Iterator for DynamicStringIterator type Item = u16;
[src]
Notable traits for DynamicStringIterator
impl Iterator for DynamicStringIterator type Item = u16;
Returns an iterator over the characters in this string.
Trait Implementations
impl<T: Into<DynamicString>> Add<T> for DynamicString
[src]
type Output = DynamicString
The resulting type after applying the +
operator.
pub fn add(self, rhs: T) -> Self::Output
[src]
impl Clone for DynamicString
[src]
pub fn clone(&self) -> DynamicString
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for DynamicString
[src]
impl Display for DynamicString
[src]
impl Eq for DynamicString
[src]
impl<'_> From<&'_ DynamicString> for IndexedString
[src]
pub fn from(string: &DynamicString) -> Self
[src]
impl<'_> From<&'_ DynamicString> for String
[src]
pub fn from(str: &DynamicString) -> Self
[src]
impl From<DynamicString> for IndexedString
[src]
pub fn from(string: DynamicString) -> Self
[src]
impl From<DynamicString> for String
[src]
pub fn from(str: DynamicString) -> Self
[src]
impl Hash for DynamicString
[src]
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'_> Into<DynamicString> for &'_ str
[src]
pub fn into(self) -> DynamicString
[src]
impl IntoIterator for DynamicString
[src]
type Item = u16
The type of the elements being iterated over.
type IntoIter = DynamicStringIterator
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> Self::IntoIter
[src]
impl Ord for DynamicString
[src]
pub fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<'_> PartialEq<&'_ str> for DynamicString
[src]
pub fn eq(&self, other: &&str) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<DynamicString> for DynamicString
[src]
pub fn eq(&self, other: &DynamicString) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<str> for DynamicString
[src]
pub fn eq(&self, other: &str) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<DynamicString> for DynamicString
[src]
Auto Trait Implementations
impl RefUnwindSafe for DynamicString
impl Send for DynamicString
impl Sync for DynamicString
impl Unpin for DynamicString
impl UnwindSafe for DynamicString
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,