Fix doc test.
This commit is contained in:
parent
01c35808cb
commit
a07faf7dd9
@ -3,12 +3,12 @@
|
|||||||
use crate::ast::Expr;
|
use crate::ast::Expr;
|
||||||
use crate::engine::EvalContext;
|
use crate::engine::EvalContext;
|
||||||
use crate::func::native::SendSync;
|
use crate::func::native::SendSync;
|
||||||
|
use crate::parser::ParseResult;
|
||||||
use crate::r#unsafe::unsafe_try_cast;
|
use crate::r#unsafe::unsafe_try_cast;
|
||||||
use crate::tokenizer::{is_valid_identifier, Token};
|
use crate::tokenizer::{is_valid_identifier, Token};
|
||||||
use crate::types::dynamic::Variant;
|
use crate::types::dynamic::Variant;
|
||||||
use crate::{
|
use crate::{
|
||||||
Engine, Identifier, ImmutableString, LexError, ParseError, Position, RhaiResult, Shared,
|
Engine, Identifier, ImmutableString, LexError, Position, RhaiResult, Shared, StaticVec, INT,
|
||||||
StaticVec, INT,
|
|
||||||
};
|
};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use std::prelude::v1::*;
|
use std::prelude::v1::*;
|
||||||
@ -47,11 +47,11 @@ pub type FnCustomSyntaxEval = dyn Fn(&mut EvalContext, &[Expression]) -> RhaiRes
|
|||||||
/// A general expression parsing trait object.
|
/// A general expression parsing trait object.
|
||||||
#[cfg(not(feature = "sync"))]
|
#[cfg(not(feature = "sync"))]
|
||||||
pub type FnCustomSyntaxParse =
|
pub type FnCustomSyntaxParse =
|
||||||
dyn Fn(&[ImmutableString], &str) -> Result<Option<ImmutableString>, ParseError>;
|
dyn Fn(&[ImmutableString], &str) -> ParseResult<Option<ImmutableString>>;
|
||||||
/// A general expression parsing trait object.
|
/// A general expression parsing trait object.
|
||||||
#[cfg(feature = "sync")]
|
#[cfg(feature = "sync")]
|
||||||
pub type FnCustomSyntaxParse =
|
pub type FnCustomSyntaxParse =
|
||||||
dyn Fn(&[ImmutableString], &str) -> Result<Option<ImmutableString>, ParseError> + Send + Sync;
|
dyn Fn(&[ImmutableString], &str) -> ParseResult<Option<ImmutableString>> + Send + Sync;
|
||||||
|
|
||||||
/// An expression sub-tree in an [`AST`][crate::AST].
|
/// An expression sub-tree in an [`AST`][crate::AST].
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -216,7 +216,7 @@ impl Engine {
|
|||||||
symbols: &[S],
|
symbols: &[S],
|
||||||
scope_may_be_changed: bool,
|
scope_may_be_changed: bool,
|
||||||
func: impl Fn(&mut EvalContext, &[Expression]) -> RhaiResult + SendSync + 'static,
|
func: impl Fn(&mut EvalContext, &[Expression]) -> RhaiResult + SendSync + 'static,
|
||||||
) -> Result<&mut Self, ParseError> {
|
) -> ParseResult<&mut Self> {
|
||||||
use markers::*;
|
use markers::*;
|
||||||
|
|
||||||
let mut segments = StaticVec::<ImmutableString>::new();
|
let mut segments = StaticVec::<ImmutableString>::new();
|
||||||
@ -357,7 +357,7 @@ impl Engine {
|
|||||||
pub fn register_custom_syntax_raw(
|
pub fn register_custom_syntax_raw(
|
||||||
&mut self,
|
&mut self,
|
||||||
key: impl Into<Identifier>,
|
key: impl Into<Identifier>,
|
||||||
parse: impl Fn(&[ImmutableString], &str) -> Result<Option<ImmutableString>, ParseError>
|
parse: impl Fn(&[ImmutableString], &str) -> ParseResult<Option<ImmutableString>>
|
||||||
+ SendSync
|
+ SendSync
|
||||||
+ 'static,
|
+ 'static,
|
||||||
scope_may_be_changed: bool,
|
scope_may_be_changed: bool,
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
//!
|
//!
|
||||||
//! # #[cfg(not(feature = "no_std"))]
|
//! # #[cfg(not(feature = "no_std"))]
|
||||||
//! # #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
|
//! # #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
|
||||||
//! // Evaluate the script, expects a 'bool' return
|
//! // Evaluate the script, expecting a 'bool' result
|
||||||
//! let result = engine.eval_file::<bool>("my_script.rhai".into())?,
|
//! let result = engine.eval_file::<bool>("my_script.rhai".into())?;
|
||||||
//!
|
//!
|
||||||
//! assert_eq!(result, true);
|
//! assert_eq!(result, true);
|
||||||
//!
|
//!
|
||||||
|
Loading…
Reference in New Issue
Block a user