multiavatar 1.0.0

Multiavatar pure Rust implementation — 移植自 multiavatar.js(Gie Katon),确定性多文化头像生成器,零运行时文件依赖
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! 字符串小工具。

/// 两位补零格式化(与 JS 中 nr.length==1 时补 '0' 的语义一致)。
pub fn two(x: i32) -> String {
    if x < 10 {
        format!("0{}", x)
    } else {
        x.to_string()
    }
}

/// 是否为空字符串(null 视为空)。
pub fn is_empty(s: Option<&str>) -> bool {
    match s {
        None => true,
        Some(v) => v.is_empty(),
    }
}