Struct repl_framework::Repl [−][src]
The main Repl Struct which contains pretty much everything the crate has to offer
Fields
data: HashMap<String, Arc<dyn Any>>
Implementations
impl Repl
[src]
impl Repl
[src]Repl methods
pub fn take_arg_return(&self) -> Vec<String>
[src]
same as take_arg, but returns the argument instead of storing it in self.argument
pub fn custom(
data: HashMap<String, Arc<dyn Any>>,
prompt: &str,
exit: &str,
functions: HashMap<String, fn(_: HashMap<String, Arc<dyn Any>>, _: Vec<String>)>
) -> Repl
[src]
data: HashMap<String, Arc<dyn Any>>,
prompt: &str,
exit: &str,
functions: HashMap<String, fn(_: HashMap<String, Arc<dyn Any>>, _: Vec<String>)>
) -> Repl
returns a customized Repl currently not much different from normal new other than the choice of exit keyword
Example
ⓘ
use repl_framework::Repl; fn main() { let mut repl = Repl::custom( prompt: &str, exit: &str, functions: HashMap<String, fn(Vec<String>)> ); }
pub fn new(prompt: &str) -> Repl
[src]
returns new repl
Example
ⓘ
use repl_framework::Repl; fn test(_: Vec<String>) { println!("test"); } fn main() { let mut repl = Repl::new(">>> "); repl.add_function("test", test as fn(Vec<String>)); repl.run(); }
pub fn from_interpreter(
interpreter: Interpreter,
prompt: &str,
exit: &str
) -> Repl
[src]
interpreter: Interpreter,
prompt: &str,
exit: &str
) -> Repl
pub fn add_function(
&mut self,
name: String,
func: fn(_: HashMap<String, Arc<dyn Any>>, _: Vec<String>)
)
[src]
&mut self,
name: String,
func: fn(_: HashMap<String, Arc<dyn Any>>, _: Vec<String>)
)
pub fn run(&mut self)
[src]
runs the repl
Example
ⓘ
use repl_framework::Repl; use std::collections::HashMap; fn test(_: Vec<String>) { println!("test!"); } fn main() { let mut hashmap = HashMap::new(); hashmap.insert("test".to_string(), test as fn(Vec<String>)); let mut repl = Repl::new(">>> ", hashmap); repl.run() }
pub fn run_debug(&mut self)
[src]
Runs the repl in debug mode
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Repl
impl !RefUnwindSafe for Repl
impl !UnwindSafe for Repl
impl !UnwindSafe for Repl