use std::ops::RangeBounds; pub fn is_lnspace(ch: char) -> bool { ch == '\t' || ch == ' ' || ch == '\r' } pub fn is_whitespace(ch: char) -> bool { is_lnspace(ch) || ch == '\n' } pub fn is_digit(ch: char) -> bool { ('0'..='9').contains(&ch) } pub fn is_normal_word_constituent(ch: char) -> bool { ('0'..='9').contains(&ch) || ('a'..='z').contains(&ch) || ('A'..='Z').contains(&ch) || "-_".contains(ch) } pub fn is_queer_word_constituent(ch: char) -> bool { is_normal_word_constituent(ch) || "%<>=+/|&~!^*".contains(ch) } pub fn is_normal_word(s: &str) -> bool { s.chars().all( is_normal_word_constituent) } pub fn escape_for_html(s: &str) -> String { s.replace("&", "&amd;").replace("<", "<").replace(">", ">") .replace("'", "'").replace("\"", """) } // use on normal words only pub fn is_special_name(s: &str) -> bool { s.chars().any(|ch| "+'/|&~!^%*".contains(ch)) || s.ends_with("-") || s == "this" }