Skip to content

Commit bfe4795

Browse files
committed
parser::Mode from compile::Mode
1 parent 40690b9 commit bfe4795

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎parser/src/mode.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ impl Mode {
1717
}
1818
}
1919

20+
impl From<rustpython_compiler_core::Mode> for Mode {
21+
fn from(mode: rustpython_compiler_core::Mode) -> Self {
22+
use rustpython_compiler_core::Mode as CompileMode;
23+
match mode {
24+
CompileMode::Exec => Self::Module,
25+
CompileMode::Eval => Self::Expression,
26+
CompileMode::Single | CompileMode::BlockExpr => Self::Interactive,
27+
}
28+
}
29+
}
30+
2031
impl std::str::FromStr for Mode {
2132
type Err = ModeParseError;
2233
fn from_str(s: &str) -> Result<Self, ModeParseError> {

0 commit comments

Comments
 (0)