pub fn reverse_string(string_value: &str) -> StringExpand description
Compacts the standar string_value.chars().rev().collect() into a single call, to improve
readability.
§Arguments
string_value- The string to be reversed by the function.
§Returns
The reversed input string.
§Panics
This function does not panic under normal circumstances.
§Examples
-
Reversing a input string:
use rusty_utils::reverse_string; let mut input: &str = "Hello, World"; //It's not necesary to trim the string, since it will work regardless, //but is more aesthetically pleasing. let sentence = input.trim(); let reversed_sentence = reverse_string(sentence); assert_eq!(reversed_sentence, "dlroW ,olleH");