Use INT in examples instead of i64.

This commit is contained in:
Stephen Chung 2020-03-24 09:49:08 +08:00
parent 1b4bcbcfdf
commit 060a61fc9d
6 changed files with 14 additions and 14 deletions

View File

@ -1,8 +1,8 @@
use rhai::{Engine, RegisterFn}; use rhai::{Engine, RegisterFn, INT};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
struct TestStruct { struct TestStruct {
x: i64, x: INT,
} }
impl TestStruct { impl TestStruct {

View File

@ -1,8 +1,8 @@
use rhai::{Engine, EvalAltResult, RegisterFn}; use rhai::{Engine, EvalAltResult, RegisterFn, INT};
#[derive(Clone)] #[derive(Clone)]
struct TestStruct { struct TestStruct {
x: i64, x: INT,
} }
impl TestStruct { impl TestStruct {

View File

@ -1,9 +1,9 @@
use rhai::{Engine, EvalAltResult}; use rhai::{Engine, EvalAltResult, INT};
fn main() -> Result<(), EvalAltResult> { fn main() -> Result<(), EvalAltResult> {
let mut engine = Engine::new(); let mut engine = Engine::new();
let result = engine.eval::<i64>("40 + 2")?; let result = engine.eval::<INT>("40 + 2")?;
println!("Answer: {}", result); // prints 42 println!("Answer: {}", result); // prints 42

View File

@ -1,13 +1,13 @@
#![cfg_attr(feature = "no_std", no_std)] #![cfg_attr(feature = "no_std", no_std)]
use rhai::{Engine, EvalAltResult}; use rhai::{Engine, EvalAltResult, INT};
fn main() -> Result<(), EvalAltResult> { fn main() -> Result<(), EvalAltResult> {
let mut engine = Engine::new(); let mut engine = Engine::new();
let result = engine.eval::<i64>("40 + 2")?; let result = engine.eval::<INT>("40 + 2")?;
assert_eq!(result, 42); println!("Answer: {}", 42);
Ok(()) Ok(())
} }

View File

@ -1,4 +1,4 @@
use rhai::{Engine, EvalAltResult, Scope}; use rhai::{Engine, EvalAltResult, Scope, INT};
fn main() -> Result<(), EvalAltResult> { fn main() -> Result<(), EvalAltResult> {
let mut engine = Engine::new(); let mut engine = Engine::new();
@ -6,7 +6,7 @@ fn main() -> Result<(), EvalAltResult> {
engine.eval_with_scope::<()>(&mut scope, "let x = 4 + 5")?; engine.eval_with_scope::<()>(&mut scope, "let x = 4 + 5")?;
let result = engine.eval_with_scope::<i64>(&mut scope, "x")?; let result = engine.eval_with_scope::<INT>(&mut scope, "x")?;
println!("result: {}", result); println!("result: {}", result);

View File

@ -1,15 +1,15 @@
use rhai::{Engine, EvalAltResult, RegisterFn}; use rhai::{Engine, EvalAltResult, RegisterFn, INT};
fn main() -> Result<(), EvalAltResult> { fn main() -> Result<(), EvalAltResult> {
let mut engine = Engine::new(); let mut engine = Engine::new();
fn add(x: i64, y: i64) -> i64 { fn add(x: INT, y: INT) -> INT {
x + y x + y
} }
engine.register_fn("add", add); engine.register_fn("add", add);
let result = engine.eval::<i64>("add(40, 2)")?; let result = engine.eval::<INT>("add(40, 2)")?;
println!("Answer: {}", result); // prints 42 println!("Answer: {}", result); // prints 42