[−][src]Struct rant::Rant
A Rant execution context.
Implementations
impl Rant
[src]
pub fn new() -> Self
[src]
Creates a new Rant context with the default seed (0) and loads the standard library.
pub fn with_seed(seed: u64) -> Self
[src]
Creates a new Rant context with the specified seed and loads the standard library.
pub fn with_random_seed() -> Self
[src]
Creates a new Rant context with a seed generated by a thread-local PRNG and loads the standard library.
pub fn with_options(options: RantOptions) -> Self
[src]
Creates a new Rant context with the specified options.
impl Rant
[src]
#[must_use =
"compiling a program without storing or running it achieves nothing"]pub fn compile<R: Reporter>(
&self,
source: &str,
reporter: &mut R
) -> Result<RantProgram, CompilerErrorKind>
[src]
&self,
source: &str,
reporter: &mut R
) -> Result<RantProgram, CompilerErrorKind>
Compiles a source string using the specified reporter.
#[must_use =
"compiling a program without storing or running it achieves nothing"]pub fn compile_named<R: Reporter>(
&self,
source: &str,
reporter: &mut R,
name: &str
) -> Result<RantProgram, CompilerErrorKind>
[src]
&self,
source: &str,
reporter: &mut R,
name: &str
) -> Result<RantProgram, CompilerErrorKind>
Compiles a source string using the specified reporter and source name.
#[must_use =
"compiling a program without storing or running it achieves nothing"]pub fn compile_quiet(
&self,
source: &str
) -> Result<RantProgram, CompilerErrorKind>
[src]
&self,
source: &str
) -> Result<RantProgram, CompilerErrorKind>
Compiles a source string without reporting problems.
Note
This method will not generate any compiler messages, even if it fails.
If you require this information, use the compile()
method instead.
#[must_use =
"compiling a program without storing or running it achieves nothing"]pub fn compile_quiet_named(
&self,
source: &str,
name: &str
) -> Result<RantProgram, CompilerErrorKind>
[src]
&self,
source: &str,
name: &str
) -> Result<RantProgram, CompilerErrorKind>
Compiles a source string without reporting problems and assigns it the specified name.
Note
This method will not generate any compiler messages, even if it fails.
If you require this information, use the compile()
method instead.
#[must_use =
"compiling a program without storing or running it achieves nothing"]pub fn compile_file<P: AsRef<Path>, R: Reporter>(
&self,
path: P,
reporter: &mut R
) -> Result<RantProgram, CompilerErrorKind>
[src]
&self,
path: P,
reporter: &mut R
) -> Result<RantProgram, CompilerErrorKind>
Compiles a source file using the specified reporter.
#[must_use =
"compiling a program without storing or running it achieves nothing"]pub fn compile_file_quiet<P: AsRef<Path>>(
&self,
path: P
) -> Result<RantProgram, CompilerErrorKind>
[src]
&self,
path: P
) -> Result<RantProgram, CompilerErrorKind>
Compiles a source file without reporting problems.
Note
This method will not generate any compiler messages, even if it fails.
If you require this information, use the compile_file()
method instead.
pub fn set_global(&mut self, key: &str, value: RantValue)
[src]
Sets a global variable.
pub fn get_global(&self, key: &str) -> Option<RantValue>
[src]
Gets the value of a global variable.
pub fn has_global(&self, key: &str) -> bool
[src]
Returns true
if a global with the specified key exists.
pub fn delete_global(&mut self, key: &str) -> bool
[src]
Removes the global with the specified key. Returns true
if the global existed prior to removal.
pub fn global_names(&self) -> impl Iterator<Item = &str>
[src]
Iterates over the names of all globals stored in the context.
pub fn seed(&self) -> u64
[src]
Gets the current RNG seed.
pub fn set_seed(&mut self, seed: u64)
[src]
Re-seeds the RNG with the specified seed.
pub fn reset_seed(&mut self)
[src]
Resets the RNG back to its initial state with the current seed.
pub fn run(&mut self, program: &RantProgram) -> RuntimeResult<RantValue>
[src]
Runs a program and returns the output value.
pub fn run_with<A>(
&mut self,
program: &RantProgram,
args: A
) -> RuntimeResult<RantValue> where
A: Into<Option<HashMap<String, RantValue>>>,
[src]
&mut self,
program: &RantProgram,
args: A
) -> RuntimeResult<RantValue> where
A: Into<Option<HashMap<String, RantValue>>>,
Runs a program with the specified arguments and returns the output value.
pub fn run_into_string(
&mut self,
program: &RantProgram
) -> RuntimeResult<String>
[src]
&mut self,
program: &RantProgram
) -> RuntimeResult<String>
Runs a Rant program and returns the generated output as a string.
pub fn run_into_string_with<A>(
&mut self,
program: &RantProgram,
args: A
) -> RuntimeResult<String> where
A: Into<Option<HashMap<String, RantValue>>>,
[src]
&mut self,
program: &RantProgram,
args: A
) -> RuntimeResult<String> where
A: Into<Option<HashMap<String, RantValue>>>,
Runs a Rant program with the specified arguments and returns the generated output as a string.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Rant
[src]
impl !Send for Rant
[src]
impl !Sync for Rant
[src]
impl Unpin for Rant
[src]
impl !UnwindSafe for Rant
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,