Crate string_manipulation_utf8

Source

Macros§

str_concat
Macro to concatenate multiple strings. Allocates the needed capacity and adds the stings. All strings are borrowed. Example: let s: String = str_concat!(&s1, &s2, &s3); The arguments are string slices (&str). The number of arguments can be 2 or more. Example: fn main() { let s1: String = “string1”.to_owned(); let s2: String = “string2”.to_owned(); let s3: String = “string3”.to_owned(); let result1: String = str_concat!(&s1, &s2, &s3); let result2: String = str_concat!(&s1, “string2”, &s3); }

Traits§

CharString

Functions§

indexof
Get the character position from one string into another. Start searching from character index ‘start_index’. Returns None if not found. Index of the first character is 0.
str_remove
Remove a substring from a string. Beginning at character index ‘start_index’ and take ‘length’ characters. Index of the first character is 0.
substr
Get a substring of a string, beginning at character index ‘start_index’ and take ‘length’ characters. Index of the first character is 0. Negative numbers count backwards: ‘start_index’ from the end of the string. ‘length’ from ‘start_index’. If start_index exceeds the string boundary limits, return an empty string. (Similar to C++ std::substr() and c# String.Substring.) Examples: “0123456789”.substr(2, 3) => “234” “0123456789”.substr(-5, 3) => “567” “0123456789”.substr(-5, -3) => “345” “0123456789”.substr(5, -3) => “345” “0123456789”.substr(2, 0) => “” “0123456789”.substr(0, 0) => “” “0123456789”.substr(-4, 0) => “” To get the characters until the end of the string: “0123456789”.substr(2, isize::MAX) => “23456789” Or substr_end(start_index) “0123456789”.substr_end(2) => “23456789”
substr_end
Get a substring from character index ‘start_index’ till end of the string. ‘start_index’ can be negative to count backwards from the end. If start_index exceeds the string boundary limits, return an empty string (0, 0). (Similar to C++ std::substr() and c# String.Substring.) Index of the first character is 0.
substring
Get a substring of a string beginning at character index start_index up to and excluding the character index end_index. Equivalent of JavaScript substring with 2 parameters. If start_index is equal to end_index, substring() returns an empty string. If start_index is greater than end_index, swap start_index and end_index. Any argument value that is less than 0 is treated as if it were 0. Any argument value that is greater than string length is treated as if it were string length. Index of the first character is 0.
substru
Get a substring of a string, beginning at character index ‘start_index’ and take ‘length’ characters. Using unsigned start_index and length. Index of the first character is 0.