proc_macro2/num.rs
1// TODO: use NonZero<char> in Rust 1.89+
2#[derive(Copy, Clone, Debug, PartialEq, Eq)]
3pub struct NonZeroChar(char);
4
5impl NonZeroChar {
6 pub fn new(ch: char) -> Option<Self> {
7 if ch == '\0' {
8 None
9 } else {
10 Some(NonZeroChar(ch))
11 }
12 }
13
14 pub fn get(self) -> char {
15 self.0
16 }
17}