taesik

Masking with # except last 4 string 본문

functions and trick/RUST

Masking with # except last 4 string

taesikk 2022. 6. 9. 16:29
     "64607935616" -->      "#######5616"
               "1" -->                "1"
                "" -->                 ""

 

 

 

fn maskify(cc: &str) -> String {
    let mask_length = cc.len().saturating_sub(4);
    "#".repeat(mask_length) + &cc[mask_length..]
}

'functions and trick > RUST' 카테고리의 다른 글

return the number of vowels  (0) 2022.06.09
Break camelCase  (0) 2022.06.06
Largest 5 digit number in a series  (0) 2022.06.06