#[non_exhaustive]pub struct Output { /* private fields */ }
Expand description
What to do with the output of an instruction.
Implementations§
Source§impl Output
impl Output
Sourcepub fn store<M, O>(self, stack: &mut M, o: O) -> Result<(), RuntimeError>
pub fn store<M, O>(self, stack: &mut M, o: O) -> Result<(), RuntimeError>
Write output using the provided IntoOutput
implementation onto the
stack.
The IntoOutput
trait primarily allows for deferring a computation
since it’s implemented by FnOnce
. However, you must take care that
any side effects calling a function may have are executed outside of the
call to store
. Like if the function would error.
§Examples
use rune::runtime::{Output, Memory, ToValue, VmResult, InstAddress};
use rune::vm_try;
fn sum(stack: &mut dyn Memory, addr: InstAddress, args: usize, out: Output) -> VmResult<()> {
let mut number = 0;
for value in vm_try!(stack.slice_at(addr, args)) {
number += vm_try!(value.as_integer::<i64>());
}
out.store(stack, number);
VmResult::Ok(())
}
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Output
impl<'de> Deserialize<'de> for Output
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Output
impl Eq for Output
impl StructuralPartialEq for Output
Auto Trait Implementations§
impl Freeze for Output
impl RefUnwindSafe for Output
impl Send for Output
impl Sync for Output
impl Unpin for Output
impl UnwindSafe for Output
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.