Trait string_patterns::ToSegments
source · pub trait ToSegments {
Show 13 methods
// Required methods
fn to_segments(&self, separator: &str) -> Vec<Self>
where Self: Sized;
fn to_parts(&self, separator: &str) -> Vec<Self>
where Self: Sized;
fn to_head(&self, separator: &str) -> Self
where Self: Sized;
fn to_first(&self, separator: &str) -> Self
where Self: Sized;
fn to_remainder_end(&self, separator: &str) -> Self
where Self: Sized;
fn to_last(&self, separator: &str) -> Self
where Self: Sized;
fn to_remainder_start(&self, separator: &str) -> Self
where Self: Sized;
fn to_end(&self, separator: &str) -> Self
where Self: Sized;
fn to_segment(&self, separator: &str, index: i32) -> Option<Self>
where Self: Sized;
fn to_inner_segment(&self, groups: &[(&str, i32)]) -> Option<Self>
where Self: Sized;
fn to_tail(&self, separator: &str) -> Self
where Self: Sized;
fn to_head_tail(&self, separator: &str) -> (Self, Self)
where Self: Sized;
fn to_start_end(&self, separator: &str) -> (Self, Self)
where Self: Sized;
}
Required Methods§
sourcefn to_segments(&self, separator: &str) -> Vec<Self>where
Self: Sized,
fn to_segments(&self, separator: &str) -> Vec<Self>where
Self: Sized,
Extract a vector of non-empty strings from a string-like object with a given separator excluding leading, trailing or double separators
sourcefn to_parts(&self, separator: &str) -> Vec<Self>where
Self: Sized,
fn to_parts(&self, separator: &str) -> Vec<Self>where
Self: Sized,
Extract a vector of strings from a string-like object with a given separator
sourcefn to_head(&self, separator: &str) -> Selfwhere
Self: Sized,
fn to_head(&self, separator: &str) -> Selfwhere
Self: Sized,
Extract only the head before the first occurrence of a separator
sourcefn to_first(&self, separator: &str) -> Selfwhere
Self: Sized,
fn to_first(&self, separator: &str) -> Selfwhere
Self: Sized,
Extract only the first segment before the first occurrence of a non-initial separator
sourcefn to_remainder_end(&self, separator: &str) -> Selfwhere
Self: Sized,
fn to_remainder_end(&self, separator: &str) -> Selfwhere
Self: Sized,
Extract only the remainder after the first occurrence of a non-initial separator
sourcefn to_last(&self, separator: &str) -> Selfwhere
Self: Sized,
fn to_last(&self, separator: &str) -> Selfwhere
Self: Sized,
Extract only the last segment after the last occurrence of a non-final separator
sourcefn to_remainder_start(&self, separator: &str) -> Selfwhere
Self: Sized,
fn to_remainder_start(&self, separator: &str) -> Selfwhere
Self: Sized,
Extract only the beginning before the last segment following the last occurrence of a non-final separator
sourcefn to_segment(&self, separator: &str, index: i32) -> Option<Self>where
Self: Sized,
fn to_segment(&self, separator: &str, index: i32) -> Option<Self>where
Self: Sized,
Extract a string-like segment identified by its index from the components of a string with a given separator e.g. String::from(“10/11/2024”) .to_segment(1) yields “11”
fn to_inner_segment(&self, groups: &[(&str, i32)]) -> Option<Self>where
Self: Sized,
sourcefn to_tail(&self, separator: &str) -> Selfwhere
Self: Sized,
fn to_tail(&self, separator: &str) -> Selfwhere
Self: Sized,
extract the remainder after the head
sourcefn to_head_tail(&self, separator: &str) -> (Self, Self)where
Self: Sized,
fn to_head_tail(&self, separator: &str) -> (Self, Self)where
Self: Sized,
extract the first and last parts after the first occurrence of the separator
sourcefn to_start_end(&self, separator: &str) -> (Self, Self)where
Self: Sized,
fn to_start_end(&self, separator: &str) -> (Self, Self)where
Self: Sized,
extract the first and last parts after the last occurrence of the separator
Implementations on Foreign Types§
source§impl ToSegments for String
impl ToSegments for String
source§fn to_last(&self, separator: &str) -> String
fn to_last(&self, separator: &str) -> String
Extract only the last segment after the last occurrence of a non-final separator
source§fn to_first(&self, separator: &str) -> String
fn to_first(&self, separator: &str) -> String
Extract only the first segment before the first occurrence of a non-initial separator
source§fn to_remainder_end(&self, separator: &str) -> String
fn to_remainder_end(&self, separator: &str) -> String
Extract only the remainder after the first occurrence of a non-initial separator
source§fn to_remainder_start(&self, separator: &str) -> String
fn to_remainder_start(&self, separator: &str) -> String
Extract only the beginning before the last segment following the last occurrence of a non-final separator
source§fn to_segment(&self, separator: &str, index: i32) -> Option<String>
fn to_segment(&self, separator: &str, index: i32) -> Option<String>
Extract an indexed segment yielded by splitting a string. A negative index parameter will start from the end
source§fn to_head_tail(&self, separator: &str) -> (String, String)
fn to_head_tail(&self, separator: &str) -> (String, String)
Extract a tuple of the head and remainder, like split_once but returns Strings
source§fn to_start_end(&self, separator: &str) -> (String, String)
fn to_start_end(&self, separator: &str) -> (String, String)
Extract a tuple of the tail and remainder, like split_once in reverse and returning strings