Implement From<&str> for Program
This commit is contained in:
parent
83bf4b3bac
commit
dd6a64539a
@ -96,6 +96,13 @@ impl Program {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for Program {
|
||||
fn from(value: &str) -> Self {
|
||||
let (_, program) = read_program(value).unwrap();
|
||||
program
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for Program {
|
||||
type Item = Node;
|
||||
|
||||
|
@ -4,6 +4,6 @@ mod basic;
|
||||
|
||||
fn main() {
|
||||
let file = fs::read_to_string("./inputs/simple_program.bas").unwrap();
|
||||
let (_, mut program) = basic::read_program(&file).unwrap();
|
||||
let mut program = basic::Program::from(file.as_str());
|
||||
program.execute();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user