@@ -1,6 +1,3 @@
|
||||
#![cfg(not(feature = "no_index"))]
|
||||
#![cfg(not(feature = "no_object"))]
|
||||
|
||||
use rhai::{Engine, EvalAltResult};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -17,6 +14,8 @@ impl TestStruct {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
@@ -47,3 +46,8 @@ fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "no_index", feature = "no_object"))]
|
||||
fn main() {
|
||||
panic!("This example does not run under 'no_index' or 'no_object'.")
|
||||
}
|
||||
|
@@ -1,5 +1,3 @@
|
||||
#![cfg(not(feature = "no_object"))]
|
||||
|
||||
use rhai::{Engine, EvalAltResult};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -17,6 +15,7 @@ impl TestStruct {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
@@ -37,3 +36,8 @@ fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "no_object")]
|
||||
fn main() {
|
||||
panic!("This example does not run under 'no_object'.");
|
||||
}
|
||||
|
@@ -1,6 +1,19 @@
|
||||
#![cfg(feature = "serde")]
|
||||
#![cfg(not(feature = "no_object"))]
|
||||
#[cfg(any(not(feature = "serde"), feature = "no_object"))]
|
||||
fn main() {
|
||||
println!("This example requires the 'serde' feature to run.");
|
||||
println!("Try: cargo run --features serde --example serde");
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
fn main() {
|
||||
example::ser();
|
||||
println!();
|
||||
example::de();
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
mod example {
|
||||
use rhai::serde::{from_dynamic, to_dynamic};
|
||||
use rhai::{Dynamic, Engine, Map};
|
||||
@@ -75,9 +88,3 @@ mod example {
|
||||
println!("Deserialized to struct: {:#?}", x);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
example::ser();
|
||||
println!();
|
||||
example::de();
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
///! This example registers a variety of functions that operate on strings.
|
||||
///! Remember to use `ImmutableString` or `&str` instead of `String` as parameters.
|
||||
#![cfg(not(feature = "no_object"))]
|
||||
|
||||
use rhai::{Engine, EvalAltResult, ImmutableString, Scope};
|
||||
use std::io::{stdin, stdout, Write};
|
||||
|
||||
@@ -66,10 +64,10 @@ fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
engine.run_with_scope(
|
||||
&mut scope,
|
||||
r#"
|
||||
display("Length", x.len);
|
||||
display("Length", x.len());
|
||||
x.trim();
|
||||
display("Trimmed", x);
|
||||
display("Trimmed Length", x.len);
|
||||
display("Trimmed Length", x.len());
|
||||
display("Index of \"!!!\"", x.index_of("!!!"));
|
||||
"#,
|
||||
)?;
|
||||
|
Reference in New Issue
Block a user