mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-30 15:18:02 +00:00
Add utilities to enum (#44)
* Add utilities to enum * Fix unexpected pyo3 dependency propagation
This commit is contained in:
parent
3bdf8a940a
commit
ff17f6e178
9 changed files with 33 additions and 17 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue