pub fn compare(s1: &String, s2: &String) -> i32
Expand description
Compares two strings lexicographically.
§Arguments
s1
- AString
to be compared.s2
- AString
to be compared.
§Returns
An i32
value indicating the result of the comparison:
0
if the strings are equal,- A negative number if
s1
is less thans2
, - A positive number if
s1
is greater thans2
.
§Examples
use rust_string_utils::compare;
let result = compare(&"abc".to_string(), &"abc".to_string());
assert_eq!(result, 0);