pub struct Repl {
pub commands: Vec<Command>,
pub items: Vec<Vec<String>>,
pub statements: Vec<Vec<String>>,
pub crates: Vec<CrateType>,
pub print: bool,
pub name: &'static str,
pub prompt_colour: Color,
pub out_colour: Color,
/* private fields */
}
Expand description
A REPL instance.
Fields
commands: Vec<Command>
The REPL handled commands. Can be extended.
ⓘ
let repl = Repl::new();
repl.commands.push(Command::new("load", CmdArgs::Filename, "load and evaluate file contents as inputs", |r, arg_text| {
r.run_file(arg_text);
}));
items: Vec<Vec<String>>
Items compiled into every program. These are functions, types, etc.
statements: Vec<Vec<String>>
Blocks of statements applied in order.
crates: Vec<CrateType>
Crates to referenced.
print: bool
Flag whether to print to stdout.
name: &'static str
App and prompt text.
prompt_colour: Color
The colour of the prompt region. ie papyrus
.
out_colour: Color
The colour of the out component. ie [out0]
.
Implementations
sourceimpl Repl
impl Repl
sourcepub fn evaluate(&mut self, code: &str) -> Result<String, String>
pub fn evaluate(&mut self, code: &str) -> Result<String, String>
Evaluate a string as a program, returning an error message if failed, or the printed value if successful.
Upon successful evaluation, the code will be added to the Repl
.
Outputs will be printed to stdout
much like when the repl is run interactively.
pub fn clean(&self)
Auto Trait Implementations
impl RefUnwindSafe for Repl
impl Send for Repl
impl Sync for Repl
impl Unpin for Repl
impl UnwindSafe for Repl
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more