Simplify chaining code.

This commit is contained in:
Stephen Chung
2022-11-19 18:41:51 +08:00
parent bf845fbd7a
commit 62d707ff84
13 changed files with 262 additions and 262 deletions

View File

@@ -26,6 +26,9 @@ pub use target::{calc_index, calc_offset_len, Target};
#[cfg(feature = "unchecked")]
mod unchecked {
use crate::{eval::GlobalRuntimeState, Dynamic, Engine, Position, RhaiResult, RhaiResultOf};
use std::borrow::Borrow;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
impl Engine {
/// Check if the number of operations stay within limit.
@@ -40,18 +43,12 @@ mod unchecked {
/// Check whether the size of a [`Dynamic`] is within limits.
#[inline(always)]
pub(crate) const fn check_data_size(&self, _: &Dynamic, _: Position) -> RhaiResultOf<()> {
Ok(())
}
/// Check a result to ensure that it is valid.
#[inline(always)]
pub(crate) const fn check_return_value(
pub(crate) const fn check_data_size<T: Borrow<Dynamic>>(
&self,
result: RhaiResult,
value: T,
_: Position,
) -> RhaiResult {
result
) -> RhaiResultOf<T> {
Ok(value)
}
}
}