Struct quetta::Text [−][src]
pub struct Text(_);
Expand description
The primary type of quetta, representing an immutable sequence of characters.
Internally, this can be either a full string or a slice into another Text
.
Can be cloned cheaply.
Implementations
Creates a new Text
by copying the provided slice.
Lifts a function &str -> &str
so it will be executed on the &str
self.
Will return none if the &str
returned by the function is not contained in self
.
Example
use quetta::Text;
let text = Text::new(" a ");
let trimmed = text.try_lift(|t| t.trim())?;
assert_eq!("a", trimmed.as_str());
Lifts a function &str -> Iterator<Item=&str>
so it will be executed on self
and returns an Iterator<Item=[
Text]>
.
If one of the &str
in the iterator is not contained in self
, the iterator will end.
Example
use quetta::Text;
let t = Text::new("A:B:C:D");
let lifted: Vec<Text> = t.try_lift_many(|s| s.split(":")).collect();
assert_eq!(4, lifted.len());
assert_eq!("A", lifted[0].as_str());
assert_eq!("B", lifted[1].as_str());
assert_eq!("C", lifted[2].as_str());
assert_eq!("D", lifted[3].as_str());
Lifts a function &str -> Iterator<Item=&str>
so it will be executed on self
and returns an Iterator<Item=[
Text]>
.
If the iterator yields a &str
that is not contained within self
, a new Text
will be created from it.
Example
use quetta::Text;
let t = Text::new("A:B:C:D");
let lifted: Vec<Text> = t.lift_many(|s| s.split(":")).collect();
assert_eq!(4, lifted.len());
assert_eq!("A", lifted[0].as_str());
assert_eq!("B", lifted[1].as_str());
assert_eq!("C", lifted[2].as_str());
assert_eq!("D", lifted[3].as_str());
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Text
impl UnwindSafe for Text
Blanket Implementations
Mutably borrows from an owned value. Read more