common-utils 0.1.2

common utils library
Documentation
/// 字符串是否为重复字符
#[allow(dead_code)]
pub fn is_repeat(val: String) -> bool {
    let mut x: u8 = 0;
    for v in val.into_bytes() {
        if x == 0 {
            x = v
        } else {
            if x != v {
                return false;
            }
        }
    }
    return true;
}

#[test]
fn test_is_repeat() {
    assert_eq!(true, is_repeat(String::from(".......")));
    assert_eq!(false, is_repeat(String::from("..x....")));
}