Logging setup

This commit is contained in:
veeso
2021-05-16 10:36:16 +02:00
parent 8c9c331d7e
commit 4e287a0231
9 changed files with 200 additions and 0 deletions

View File

@@ -152,6 +152,13 @@ pub fn fmt_path_elide(p: &Path, width: usize) -> String {
}
}
/// ### shadow_password
///
/// Return a string with the same length of input string, but each character is replaced by '*'
pub fn shadow_password(s: &str) -> String {
(0..s.len()).map(|_| '*').collect()
}
#[cfg(test)]
mod tests {
@@ -219,4 +226,9 @@ mod tests {
let p: &Path = &Path::new("/develop/pippo/foo/bar");
assert_eq!(fmt_path_elide(p, 16), String::from("/develop/.../foo/bar"));
}
#[test]
fn test_utils_fmt_shadow_password() {
assert_eq!(shadow_password("foobar"), String::from("******"));
}
}