pub struct HeadTailStr<'a> { /* private fields */ }Expand description
Struct returned from HeadTail::head_tail()
This struct:
Implementations§
Source§impl<'a> HeadTailStr<'a>
impl<'a> HeadTailStr<'a>
Sourcepub const fn cut(&self) -> bool
pub const fn cut(&self) -> bool
Returns true is the string was cut in any way.
Returns false if running .to_string() on this
would result in the same string as the input string.
Sourcepub const fn into_parts(self) -> (&'a str, Option<&'a str>)
pub const fn into_parts(self) -> (&'a str, Option<&'a str>)
Returns the inner head/tail str’s that make this type up.
The returned &'a str is the head portion.
If the entire input string could fit, then this will
contain the entire input string and tail will be None.
The returned Option<&'a str> is the tail portion.
If this is Some that means the input string was cut.
If it is None that means the input string was not cut
and the entire input resides inside the head portion.
let string = "hello world";
// Input (6+5 == 11) can capture the whole string.
let headtail = string.head_tail(6, 5);
// So there is no tail, everything is in head.
let (head, tail) = headtail.into_parts();
assert_eq!(head, string);
assert_eq!(tail, None);
// If it can't capture it all (5+5 != 11), then there is a tail.
let headtail = string.head_tail(5, 5);
let (head, tail) = headtail.into_parts();
assert_eq!(head, "hello");
assert_eq!(tail, Some("world"));Trait Implementations§
Source§impl<'a> Clone for HeadTailStr<'a>
impl<'a> Clone for HeadTailStr<'a>
Source§fn clone(&self) -> HeadTailStr<'a>
fn clone(&self) -> HeadTailStr<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for HeadTailStr<'a>
impl<'a> Debug for HeadTailStr<'a>
Source§impl<'de: 'a, 'a> Deserialize<'de> for HeadTailStr<'a>
impl<'de: 'a, 'a> Deserialize<'de> for HeadTailStr<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for HeadTailStr<'_>
impl Display for HeadTailStr<'_>
Source§impl<'a> Hash for HeadTailStr<'a>
impl<'a> Hash for HeadTailStr<'a>
Source§impl<'a> Ord for HeadTailStr<'a>
impl<'a> Ord for HeadTailStr<'a>
Source§fn cmp(&self, other: &HeadTailStr<'a>) -> Ordering
fn cmp(&self, other: &HeadTailStr<'a>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq<&str> for HeadTailStr<'_>
impl PartialEq<&str> for HeadTailStr<'_>
Source§impl PartialEq<str> for HeadTailStr<'_>
impl PartialEq<str> for HeadTailStr<'_>
Source§impl<'a> PartialEq for HeadTailStr<'a>
impl<'a> PartialEq for HeadTailStr<'a>
Source§impl<'a> PartialOrd for HeadTailStr<'a>
impl<'a> PartialOrd for HeadTailStr<'a>
Source§impl<'a> Serialize for HeadTailStr<'a>
impl<'a> Serialize for HeadTailStr<'a>
impl<'a> Copy for HeadTailStr<'a>
impl<'a> Eq for HeadTailStr<'a>
impl<'a> StructuralPartialEq for HeadTailStr<'a>
Auto Trait Implementations§
impl<'a> Freeze for HeadTailStr<'a>
impl<'a> RefUnwindSafe for HeadTailStr<'a>
impl<'a> Send for HeadTailStr<'a>
impl<'a> Sync for HeadTailStr<'a>
impl<'a> Unpin for HeadTailStr<'a>
impl<'a> UnwindSafe for HeadTailStr<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more