Add utilities to enum (#44)

* Add utilities to enum

* Fix unexpected pyo3 dependency propagation
This commit is contained in:
Jeong, YunWon 2023-05-16 23:29:49 +09:00 committed by GitHub
parent 3bdf8a940a
commit ff17f6e178
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 17 deletions

View file

@ -11,3 +11,15 @@ pub enum ConversionFlag {
/// Converts by calling `repr(<value>)`.
Repr = b'r' as i8,
}
impl ConversionFlag {
pub fn to_byte(&self) -> Option<u8> {
match self {
Self::None => None,
flag => Some(*flag as u8),
}
}
pub fn to_char(&self) -> Option<char> {
Some(self.to_byte()? as char)
}
}

View file

@ -1,7 +1,7 @@
//! Control in the different modes by which a source file can be parsed.
/// The mode argument specifies in what way code must be parsed.
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Hash, PartialEq, Eq)]
pub enum Mode {
/// The code consists of a sequence of statements.
Module,