wc3 0.2.0

Read, edit, and write Warcraft III models, BLP textures, and MPQ archives
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Validation of enum discriminators supplied by associated constants.
#[doc(hidden)]
pub fn enum_names_valid(names: &[&str]) -> bool {
    names.iter().enumerate().all(|(index, name)| {
        let mut bytes = name.bytes();
        bytes
            .next()
            .is_some_and(|byte| byte.is_ascii_alphabetic() || byte == b'_')
            && bytes.all(|byte| byte.is_ascii_alphanumeric() || byte == b'_')
            && !name.eq_ignore_ascii_case("nan")
            && !name.eq_ignore_ascii_case("inf")
            && !names[..index].contains(name)
    })
}