rubchev 0.1.2

A Rust utility library for strings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use regex::Regex;

/// Reverses a given string.
pub fn reverse(text: &str) -> String {
    text.chars().rev().collect()
}

/// Converts all characters to uppercase.
pub fn to_uppercase(text: &str) -> String {
    text.to_uppercase()
}

/// Replaces all occurrences of `old_sub` with `new_sub` in `text`.
pub fn replace_all(text: &str, old_sub: &str, new_sub: &str) -> String {
    let re = Regex::new(old_sub).unwrap();
    re.replace_all(text, new_sub).to_string()
}