Fix builds.
This commit is contained in:
parent
e6c878edf3
commit
20aaf1826a
@ -1,6 +1,8 @@
|
||||
Rhai Release Notes
|
||||
==================
|
||||
|
||||
This version adds string interpolation.
|
||||
|
||||
Version 0.19.16
|
||||
===============
|
||||
|
||||
|
@ -140,6 +140,7 @@ fn main() {
|
||||
|
||||
// Set a file module resolver without caching
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
{
|
||||
let mut resolver = rhai::module_resolvers::FileModuleResolver::new();
|
||||
resolver.enable_cache(false);
|
||||
|
@ -36,14 +36,6 @@ mod string_functions {
|
||||
format!("{}{}", string, s).into()
|
||||
}
|
||||
}
|
||||
#[rhai_fn(name = "+=")]
|
||||
pub fn append(ctx: NativeCallContext, string: &mut ImmutableString, mut item: Dynamic) {
|
||||
let s = print_with_func(FUNC_TO_STRING, &ctx, &mut item);
|
||||
|
||||
if !s.is_empty() {
|
||||
string.make_mut().push_str(&s);
|
||||
}
|
||||
}
|
||||
#[rhai_fn(name = "+", pure)]
|
||||
pub fn add_prepend(
|
||||
ctx: NativeCallContext,
|
||||
@ -59,16 +51,13 @@ mod string_functions {
|
||||
s.into()
|
||||
}
|
||||
}
|
||||
#[rhai_fn(name = "+=")]
|
||||
pub fn prepend(ctx: NativeCallContext, item: &mut Dynamic, string: &str) {
|
||||
let mut s = print_with_func(FUNC_TO_STRING, &ctx, item);
|
||||
|
||||
if !string.is_empty() {
|
||||
s.make_mut().push_str(string);
|
||||
}
|
||||
#[rhai_fn(name = "+", name = "append")]
|
||||
pub fn add_append_str(string1: ImmutableString, string2: ImmutableString) -> ImmutableString {
|
||||
string1 + string2
|
||||
}
|
||||
|
||||
#[rhai_fn(name = "+")]
|
||||
#[rhai_fn(name = "+", name = "append")]
|
||||
pub fn add_append_unit(string: ImmutableString, _item: ()) -> ImmutableString {
|
||||
string
|
||||
}
|
||||
@ -76,8 +65,6 @@ mod string_functions {
|
||||
pub fn add_prepend_unit(_item: (), string: ImmutableString) -> ImmutableString {
|
||||
string
|
||||
}
|
||||
#[rhai_fn(name = "+=")]
|
||||
pub fn add_append_assign_unit(_string: &mut ImmutableString, _item: ()) {}
|
||||
|
||||
#[rhai_fn(name = "len", get = "len")]
|
||||
pub fn len(string: &str) -> INT {
|
||||
|
@ -1056,7 +1056,6 @@ fn parse_primary(
|
||||
}
|
||||
}
|
||||
|
||||
println!("Interpolated string: {:?}", segments);
|
||||
Expr::InterpolatedString(Box::new(segments))
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
//! Main module defining the lexer and parser.
|
||||
|
||||
use std::iter::FusedIterator;
|
||||
|
||||
use crate::engine::{
|
||||
Precedence, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR, KEYWORD_FN_PTR_CALL,
|
||||
KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_THIS, KEYWORD_TYPE_OF,
|
||||
@ -10,7 +8,7 @@ use crate::stdlib::{
|
||||
borrow::Cow,
|
||||
cell::Cell,
|
||||
char, fmt, format,
|
||||
iter::Peekable,
|
||||
iter::{FusedIterator, Peekable},
|
||||
num::NonZeroUsize,
|
||||
ops::{Add, AddAssign},
|
||||
str::{Chars, FromStr},
|
||||
|
@ -367,5 +367,21 @@ fn test_string_interpolated() -> Result<(), Box<EvalAltResult>> {
|
||||
"hello 42 worlds!"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>(
|
||||
r#"
|
||||
let x = 42;
|
||||
let y = 123;
|
||||
|
||||
`
|
||||
Undeniable logic:
|
||||
1) Hello, ${let w = `${x} world`; if x > 1 { w += "s" } w}!
|
||||
2) If ${y} > ${x} then it is ${y > x}!
|
||||
`
|
||||
"#
|
||||
)?,
|
||||
"Undeniable logic:\n1) Hello, 42 worlds!\n2) If 123 > 42 then it is true!\n",
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user