diff --git a/Cargo.toml b/Cargo.toml index 66c13ab5..54678e04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rhai" -version = "0.10.0-alpha1" +version = "0.10.1" edition = "2018" -authors = ["Jonathan Turner", "Lukáš Hozda"] +authors = ["Jonathan Turner", "Lukáš Hozda", "Stephen Chung"] description = "Embedded scripting for Rust" homepage = "https://github.com/jonathandturner/rhai" repository = "https://github.com/jonathandturner/rhai" diff --git a/README.md b/README.md index 1f670281..e0003a47 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,19 @@ You can install Rhai using crates by adding this line to your dependencies: ```toml [dependencies] -rhai = "0.10.0-alpha1" +rhai = "0.10.0" ``` -Beware that to use pre-releases (alpha and beta) you need to specify the exact version in your `Cargo.toml`. +or simply: + +```toml +[dependencies] +rhai = "*" +``` + +to use the latest version. + +Beware that in order to use pre-releases (alpha and beta) you need to specify the exact version in your `Cargo.toml`. ## Related @@ -206,6 +215,19 @@ fn main() { You can also see in this example how you can register multiple functions (or in this case multiple instances of the same function) to the same name in script. This gives you a way to overload functions and call the correct one, based on the types of the arguments, from your script. +# Override built-in functions + +Any similarly-named function defined in a script with the correct argument types overrides any built-in function. + +```rust +// Override the built-in function 'to_int' +fn to_int(num) { + print("Ha! Gotcha!" + num); +} + +print(to_int(123)); // what will happen? +``` + # Custom types and methods Here's an more complete example of working with Rust. First the example, then we'll break it into parts: @@ -477,7 +499,7 @@ fn add(x, y) { print(add(2, 3)) ``` -To return a `Dynamic` value, simply box it and return it. +To return a `Dynamic` value, simply `Box` it and return it. ```rust fn decide(yes_no: bool) -> Dynamic { @@ -543,7 +565,9 @@ print(y.len()); // prints 0 your own custom type, you need to define a specific override: ```rust -engine.register_fn("push", |list: &mut rhai::Array, item: MyType| list.push(Box::new(item))); +engine.register_fn("push", + |list: &mut Array, item: MyType| list.push(Box::new(item)) +); ``` The type of a Rhai array is `rhai::Array`. diff --git a/TODO b/TODO index b5b4fdf5..8ae9f602 100644 --- a/TODO +++ b/TODO @@ -1,11 +1,7 @@ pre 1.0: - - binary ops - basic threads - stdlib - - floats - - REPL (consume functions) 1.0: - decide on postfix/prefix operators - - ranges, rustic for-loop - advanced threads + actors - more literals