Struct repl_framework::Repl[][src]

pub struct Repl {
    pub data: HashMap<String, Arc<dyn Any>>,
    // some fields omitted
}

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]

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]

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]

pub fn add_function(
    &mut self,
    name: String,
    func: fn(_: HashMap<String, Arc<dyn Any>>, _: Vec<String>)
)
[src]

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

impl Debug for Repl[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.