Function compare

Source
pub fn compare(s1: &String, s2: &String) -> i32
Expand description

Compares two strings lexicographically.

§Arguments

  • s1 - A String to be compared.
  • s2 - A String 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 than s2,
  • A positive number if s1 is greater than s2.

§Examples

use rust_string_utils::compare;
let result = compare(&"abc".to_string(), &"abc".to_string());
assert_eq!(result, 0);