tracing_opentelemetry_ext/
masking.rs

1pub fn last4n(s: impl ToString) -> String {
2    let s = s.to_string();
3    match s.len() <= 4 {
4        true => format!("xxx{}", s),
5        _ => format!("xxx{}", &s[s.len() - 4..]),
6    }
7}
8
9#[cfg(test)]
10#[test]
11fn it_works() {
12    assert_eq!(last4n("123456789"), "xxx6789");
13    assert_eq!(last4n(""), "xxx");
14}