use crate::runtime::{Future, Output, Select, Vm, VmResult};
#[derive(Debug)]
pub(crate) enum Awaited {
Future(Future, Output),
Select(Select, Output),
}
impl Awaited {
pub(crate) async fn into_vm(self, vm: &mut Vm) -> VmResult<()> {
match self {
Self::Future(future, out) => {
let value = vm_try!(future.await.with_vm(vm));
vm_try!(out.store(vm.stack_mut(), value));
}
Self::Select(select, value_addr) => {
let (ip, value) = vm_try!(select.await.with_vm(vm));
vm.set_ip(ip);
vm_try!(value_addr.store(vm.stack_mut(), || value));
}
}
VmResult::Ok(())
}
}