diff options
Diffstat (limited to 'src/channel/validate.rs')
| -rw-r--r-- | src/channel/validate.rs | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/src/channel/validate.rs b/src/channel/validate.rs deleted file mode 100644 index 7894e0c..0000000 --- a/src/channel/validate.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::ops::Not as _; - -use unicode_segmentation::UnicodeSegmentation as _; - -use crate::name::Name; - -// Picked out of a hat. The power of two is not meaningful. -const NAME_TOO_LONG: usize = 64; - -pub fn name(name: &Name) -> bool { - let display = name.display(); - - [ - display.graphemes(true).count() < NAME_TOO_LONG, - display.chars().any(char::is_control).not(), - display.chars().next().is_some_and(|c| !c.is_whitespace()), - display.chars().last().is_some_and(|c| !c.is_whitespace()), - display - .chars() - .zip(display.chars().skip(1)) - .all(|(a, b)| !(a.is_whitespace() && b.is_whitespace())), - ] - .into_iter() - .all(|value| value) -} |
