use std::collections::HashMap;
extern crate sdl2;
use sdl2::pixels;
use sdl2::render;
pub fn string_has_duplicate_chars(s: String) -> bool {
let mut h = HashMap::new();
for ch in s.chars() {
if h.contains_key(&ch) {
return true;
}
h.insert(ch, true);
}
false
}
#[test]
fn dup_chars() {
assert!(!string_has_duplicate_chars("123".to_string()));
assert!(!string_has_duplicate_chars("".to_string()));
assert!(!string_has_duplicate_chars("aAbBcC".to_string()));
assert!(string_has_duplicate_chars("11".to_string()));
assert!(string_has_duplicate_chars("250 asdf 5".to_string()));
assert!(!string_has_duplicate_chars(
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\""
.to_string()
));
}
pub fn set_texture_color(color: &pixels::Color, texture: &mut render::Texture) {
texture.set_color_mod(color.r, color.g, color.b);
texture.set_alpha_mod(color.a);
}