From 13cde456e5cff1a7b4cc8046a19d21dc06e32216 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 10 Jun 2020 22:28:50 +0800 Subject: [PATCH] Change version to 0.15.1. --- Cargo.toml | 2 +- README.md | 18 +++++++++--------- RELEASES.md | 9 +++++++-- examples/strings.rs | 2 -- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 210b7488..5bae3961 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rhai" -version = "0.16.0" +version = "0.15.1" edition = "2018" authors = ["Jonathan Turner", "Lukáš Hozda", "Stephen Chung"] description = "Embedded scripting for Rust" diff --git a/README.md b/README.md index eee7c1c9..99ce9018 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Features to do checked arithmetic operations); for [`no-std`](#optional-features) builds, a number of additional dependencies are pulled in to provide for functionalities that used to be in `std`. -**Note:** Currently, the version is `0.16.0`, so the language and API's may change before they stabilize. +**Note:** Currently, the version is `0.15.1`, so the language and API's may change before they stabilize. What Rhai doesn't do -------------------- @@ -71,7 +71,7 @@ Install the Rhai crate on [`crates.io`](https::/crates.io/crates/rhai/) by addin ```toml [dependencies] -rhai = "0.16.0" +rhai = "0.15.1" ``` Use the latest released crate version on [`crates.io`](https::/crates.io/crates/rhai/): @@ -315,7 +315,7 @@ Functions declared with `private` are hidden and cannot be called from Rust (see ```rust // Define functions in a script. let ast = engine.compile(true, - r" + r#" // a function with two parameters: String and i64 fn hello(x, y) { x.len + y @@ -335,7 +335,7 @@ let ast = engine.compile(true, private hidden() { throw "you shouldn't see me!"; } - ")?; + "#)?; // A custom scope can also contain any variables/constants available to the functions let mut scope = Scope::new(); @@ -522,7 +522,7 @@ The following primitive types are supported natively: | **Floating-point number** (disabled with [`no_float`]) | `f32`, `f64` _(default)_ | `"f32"` or `"f64"` | `"123.4567"` etc. | | **Boolean value** | `bool` | `"bool"` | `"true"` or `"false"` | | **Unicode character** | `char` | `"char"` | `"A"`, `"x"` etc. | -| **Immutable Unicode string** | `rhai::ImmutableString` (implemented as `Rc` or `Arc`, _not_ `&str`) | `"string"` | `"hello"` etc. | +| **Immutable Unicode string** | `rhai::ImmutableString` (implemented as `Rc` or `Arc`) | `"string"` | `"hello"` etc. | | **Array** (disabled with [`no_index`]) | `rhai::Array` | `"array"` | `"[ ?, ?, ? ]"` | | **Object map** (disabled with [`no_object`]) | `rhai::Map` | `"map"` | `#{ "a": 1, "b": 2 }` | | **Timestamp** (implemented in the [`BasicTimePackage`](#packages)) | `std::time::Instant` | `"timestamp"` | _not supported_ | @@ -1039,13 +1039,13 @@ struct TestStruct { field: String } -// Remember Rhai uses 'ImmutableString' instead of 'String' impl TestStruct { - fn get_field(&mut self) -> ImmutableString { - // Make an 'ImmutableString' from a 'String' - self.field.into(0) + // Returning a 'String' is OK - Rhai converts it into 'ImmutableString' + fn get_field(&mut self) -> String { + self.field.clone() } + // Remember Rhai uses 'ImmutableString' or '&str' instead of 'String' fn set_field(&mut self, new_val: ImmutableString) { // Get a 'String' from an 'ImmutableString' self.field = (*new_val).clone(); diff --git a/RELEASES.md b/RELEASES.md index 3622167a..011c5c80 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,9 +1,12 @@ Rhai Release Notes ================== -Version 0.16.0 +Version 0.15.1 ============== +This is a minor release which enables updating indexers (via registered indexer setters) and supports functions +with `&str` parameters (maps transparently to `ImmutableString`). + Breaking changes ---------------- @@ -14,13 +17,15 @@ Breaking changes New features ------------ -* Indexers are now split into getters ans setters (which now support updates). The API is split into `Engine::register_indexer_get` and `Engine::register_indexer_set` with `Engine::register_indexer_get_set` being a shorthand. Similarly, `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn` are added. +* Indexers are now split into getters and setters (which now support updates). The API is split into `Engine::register_indexer_get` and `Engine::register_indexer_set` with `Engine::register_indexer_get_set` being a shorthand. Similarly, `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn` are added. * `Engine:register_fn` and `Engine:register_result_fn` accepts functions that take parameters of type `&str` (immutable string slice), which maps directly to `ImmutableString`. This is to avoid needing wrappers for functions taking string parameters. Version 0.15.0 ============== +This version uses immutable strings (`ImmutableString` type) and built-in operator functions (e.g. `+`, `>`, `+=`) to improve speed, plus some bug fixes. + Regression fix -------------- diff --git a/examples/strings.rs b/examples/strings.rs index 9e874377..e9d53016 100644 --- a/examples/strings.rs +++ b/examples/strings.rs @@ -74,6 +74,4 @@ fn main() -> Result<(), Box> { println!(); } - - Ok(()) }