pub trait StripCharacters<'a>: ToSegments {
Show 18 methods
// Required methods
fn alphanumeric_chars(&self) -> impl DoubleEndedIterator;
fn strip_non_alphanum(&self) -> String;
fn strip_non_digits(&self) -> String;
fn strip_by_type(&self, ct: CharType<'a>) -> String;
fn strip_by_types(&self, cts: &[CharType<'a>]) -> String;
fn filter_by_type(&self, ct: CharType<'a>) -> String;
fn filter_by_types(&self, cts: &[CharType<'a>]) -> String;
fn to_numeric_strings_strict(
&self,
separator: DecimalSeparator,
) -> Vec<String>;
fn to_numbers_strict<N>(&self, separator: DecimalSeparator) -> Vec<N>
where N: FromStr;
fn split_to_numbers<N>(&self, pattern: &str) -> Vec<N>
where N: FromStr + Copy;
fn correct_numeric_string_strict(
&self,
separator: DecimalSeparator,
) -> String;
// Provided methods
fn strip_spaces(&self) -> String { ... }
fn to_numeric_strings(&self) -> Vec<String> { ... }
fn to_numbers<N>(&self) -> Vec<N>
where N: FromStr { ... }
fn correct_numeric_string(&self) -> String { ... }
fn to_first_number<N>(&self) -> Option<N>
where N: FromStr + Copy { ... }
fn to_first_number_strict<N>(
&self,
separator: DecimalSeparator,
) -> Option<N>
where N: FromStr + Copy { ... }
fn strip_non_numeric(&self) -> String { ... }
}Expand description
Methods to strip or filter character types within strings and to extract integers or floats Set of methods to strip unwanted characters by type or extract vectors of numeric strings, integers or floats
Required Methods§
Sourcefn alphanumeric_chars(&self) -> impl DoubleEndedIterator
fn alphanumeric_chars(&self) -> impl DoubleEndedIterator
Lazily iterates the alphanumeric characters only, without allocating a String.
strip_non_alphanum is built on this; prefer this directly if you only need to
scan or compare the filtered characters rather than build an owned copy.
Double-ended, so callers needing to scan from the end can call .rev() on it.
Sourcefn strip_non_alphanum(&self) -> String
fn strip_non_alphanum(&self) -> String
Remove all non-alphanumeric characters
Sourcefn strip_non_digits(&self) -> String
fn strip_non_digits(&self) -> String
Remove all non-digit characters
Sourcefn strip_by_type(&self, ct: CharType<'a>) -> String
fn strip_by_type(&self, ct: CharType<'a>) -> String
Remove characters matching a specific type
Sourcefn strip_by_types(&self, cts: &[CharType<'a>]) -> String
fn strip_by_types(&self, cts: &[CharType<'a>]) -> String
Remove characters matching any of the specified types
Sourcefn filter_by_type(&self, ct: CharType<'a>) -> String
fn filter_by_type(&self, ct: CharType<'a>) -> String
Keep only characters matching a specific type
Sourcefn filter_by_types(&self, cts: &[CharType<'a>]) -> String
fn filter_by_types(&self, cts: &[CharType<'a>]) -> String
Keep only characters matching any of the specified types
Sourcefn to_numeric_strings_strict(&self, separator: DecimalSeparator) -> Vec<String>
fn to_numeric_strings_strict(&self, separator: DecimalSeparator) -> Vec<String>
Extract numeric strings with configurable decimal separator
Sourcefn to_numbers_strict<N>(&self, separator: DecimalSeparator) -> Vec<N>where
N: FromStr,
fn to_numbers_strict<N>(&self, separator: DecimalSeparator) -> Vec<N>where
N: FromStr,
Parse extracted numbers with configurable decimal separator
Sourcefn split_to_numbers<N>(&self, pattern: &str) -> Vec<N>
fn split_to_numbers<N>(&self, pattern: &str) -> Vec<N>
Split by pattern and extract the first number from each segment
Sourcefn correct_numeric_string_strict(&self, separator: DecimalSeparator) -> String
fn correct_numeric_string_strict(&self, separator: DecimalSeparator) -> String
Normalize numeric string separators based on decimal separator convention
Provided Methods§
Sourcefn strip_spaces(&self) -> String
fn strip_spaces(&self) -> String
Remove whitespace characters
Sourcefn to_numeric_strings(&self) -> Vec<String>
fn to_numeric_strings(&self) -> Vec<String>
Extract numeric strings using auto-detection
Sourcefn to_numbers<N>(&self) -> Vec<N>where
N: FromStr,
fn to_numbers<N>(&self) -> Vec<N>where
N: FromStr,
Parse numbers using auto-detection
Sourcefn correct_numeric_string(&self) -> String
fn correct_numeric_string(&self) -> String
Normalize numeric string separators using auto-detection
Sourcefn to_first_number<N>(&self) -> Option<N>
fn to_first_number<N>(&self) -> Option<N>
Extract the first parsed number using auto-detection, or None if empty
Sourcefn to_first_number_strict<N>(&self, separator: DecimalSeparator) -> Option<N>
fn to_first_number_strict<N>(&self, separator: DecimalSeparator) -> Option<N>
Extract the first parsed number with configurable decimal separator, or None if empty
Sourcefn strip_non_numeric(&self) -> String
fn strip_non_numeric(&self) -> String
Extract numeric strings and join them with spaces
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".