multiavatar 1.0.10

Deterministic multicultural avatar generator — pure Rust port of multiavatar.js with SVG/PNG/JPEG/GIF/favicon/ICO/data-URI outputs; part library embedded in the binary, no runtime files
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(),
    }
}