diff --git a/src/custom_syntax.rs b/src/custom_syntax.rs index f718b0e3..95ec521a 100644 --- a/src/custom_syntax.rs +++ b/src/custom_syntax.rs @@ -3,12 +3,12 @@ use crate::ast::Expr; use crate::engine::EvalContext; use crate::func::native::SendSync; +use crate::parser::ParseResult; use crate::r#unsafe::unsafe_try_cast; use crate::tokenizer::{is_valid_identifier, Token}; use crate::types::dynamic::Variant; use crate::{ - Engine, Identifier, ImmutableString, LexError, ParseError, Position, RhaiResult, Shared, - StaticVec, INT, + Engine, Identifier, ImmutableString, LexError, Position, RhaiResult, Shared, StaticVec, INT, }; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -47,11 +47,11 @@ pub type FnCustomSyntaxEval = dyn Fn(&mut EvalContext, &[Expression]) -> RhaiRes /// A general expression parsing trait object. #[cfg(not(feature = "sync"))] pub type FnCustomSyntaxParse = - dyn Fn(&[ImmutableString], &str) -> Result, ParseError>; + dyn Fn(&[ImmutableString], &str) -> ParseResult>; /// A general expression parsing trait object. #[cfg(feature = "sync")] pub type FnCustomSyntaxParse = - dyn Fn(&[ImmutableString], &str) -> Result, ParseError> + Send + Sync; + dyn Fn(&[ImmutableString], &str) -> ParseResult> + Send + Sync; /// An expression sub-tree in an [`AST`][crate::AST]. #[derive(Debug, Clone)] @@ -216,7 +216,7 @@ impl Engine { symbols: &[S], scope_may_be_changed: bool, func: impl Fn(&mut EvalContext, &[Expression]) -> RhaiResult + SendSync + 'static, - ) -> Result<&mut Self, ParseError> { + ) -> ParseResult<&mut Self> { use markers::*; let mut segments = StaticVec::::new(); @@ -357,7 +357,7 @@ impl Engine { pub fn register_custom_syntax_raw( &mut self, key: impl Into, - parse: impl Fn(&[ImmutableString], &str) -> Result, ParseError> + parse: impl Fn(&[ImmutableString], &str) -> ParseResult> + SendSync + 'static, scope_may_be_changed: bool, diff --git a/src/lib.rs b/src/lib.rs index ee86a923..6bf9da8f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,8 +42,8 @@ //! //! # #[cfg(not(feature = "no_std"))] //! # #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] -//! // Evaluate the script, expects a 'bool' return -//! let result = engine.eval_file::("my_script.rhai".into())?, +//! // Evaluate the script, expecting a 'bool' result +//! let result = engine.eval_file::("my_script.rhai".into())?; //! //! assert_eq!(result, true); //!