Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. use std::collections::HashMap;
  2.  
  3. pub fn str_is_unique(s: &str) -> bool {
  4. let mut map: HashMap<char, i32> = HashMap::new();
  5. for c in s.chars() {
  6. *map.entry(c).or_insert(0) += 1;
  7. }
  8. !map.iter().any(|(_, &v)| v > 1)
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement