pub trait ExtString {
// Required methods
fn reverse(&self) -> String;
fn pad_left(&self, pad_len: usize, c: char) -> String;
fn pad_right(&self, pad_len: usize, c: char) -> String;
fn pad_left_str(&self, pad_len: usize, s: &str) -> String;
fn pad_right_str(&self, pad_len: usize, s: &str) -> String;
fn is_numeric(&self) -> bool;
fn is_alphabetic(&self) -> bool;
fn is_alphanumeric(&self) -> bool;
fn swap_case(&self) -> String;
}Expand description
The trait that adds functionality to the String struct.
Required Methods§
Sourcefn pad_left(&self, pad_len: usize, c: char) -> String
fn pad_left(&self, pad_len: usize, c: char) -> String
Pads the left side of a string by repeating the same character until ‘pad_len’ is reached. If pad_len is shorter or equal to the character length, a simple cloned string will be returned.
Sourcefn pad_right(&self, pad_len: usize, c: char) -> String
fn pad_right(&self, pad_len: usize, c: char) -> String
Pads the right side of a string by repeating the same character until ‘pad_len’ is reached. If pad_len is shorter or equal to the character length, a simple cloned string will be returned.
Sourcefn pad_left_str(&self, pad_len: usize, s: &str) -> String
fn pad_left_str(&self, pad_len: usize, s: &str) -> String
Pads the left side of a string by repeating the same string slice until ‘pad_len’ is reached. If pad_len is shorter or equal to the character length, a simple cloned string will be returned.
Sourcefn pad_right_str(&self, pad_len: usize, s: &str) -> String
fn pad_right_str(&self, pad_len: usize, s: &str) -> String
Pads the right side of a string by repeating the same string slice until ‘pad_len’ is reached. If pad_len is shorter or equal to the character length, a simple cloned string will be returned.
Sourcefn is_numeric(&self) -> bool
fn is_numeric(&self) -> bool
Checks that all characters in a string are numeric characters.
Sourcefn is_alphabetic(&self) -> bool
fn is_alphabetic(&self) -> bool
Checks that all characters in a string are alphabetic characters.
Sourcefn is_alphanumeric(&self) -> bool
fn is_alphanumeric(&self) -> bool
Checks that all characters in a string are either numeric or alphabetic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ExtString for String
impl ExtString for String
Source§fn pad_left(&self, pad_len: usize, c: char) -> String
fn pad_left(&self, pad_len: usize, c: char) -> String
Pads the left side of a string by repeating the same character until ‘pad_len’ is reached. If pad_len is shorter or equal to the character length, a simple cloned string will be returned.
Source§fn pad_right(&self, pad_len: usize, c: char) -> String
fn pad_right(&self, pad_len: usize, c: char) -> String
Pads the right side of a string by repeating the same character until ‘pad_len’ is reached. If pad_len is shorter or equal to the character length, a simple cloned string will be returned.
Source§fn is_numeric(&self) -> bool
fn is_numeric(&self) -> bool
Checks that all characters in a string are numeric characters.
Source§fn is_alphabetic(&self) -> bool
fn is_alphabetic(&self) -> bool
Checks that all characters in a string are alphabetic characters.