Mark pure.
This commit is contained in:
parent
9f5783f1a4
commit
ae02668d08
@ -1,6 +1,15 @@
|
|||||||
Rhai Release Notes
|
Rhai Release Notes
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
Version 1.13.0
|
||||||
|
==============
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
* `map` and `filter` for arrays are marked `pure`. Warnings are added to the documentation of pure array methods that take `this` closures.
|
||||||
|
|
||||||
|
|
||||||
Version 1.12.0
|
Version 1.12.0
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
@ -651,6 +651,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `mapper` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -669,7 +671,7 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// print(y); // prints "[0, 2, 6, 12, 20]"
|
/// print(y); // prints "[0, 2, 6, 12, 20]"
|
||||||
/// ```
|
/// ```
|
||||||
#[rhai_fn(return_raw)]
|
#[rhai_fn(return_raw, pure)]
|
||||||
pub fn map(ctx: NativeCallContext, array: &mut Array, map: FnPtr) -> RhaiResultOf<Array> {
|
pub fn map(ctx: NativeCallContext, array: &mut Array, map: FnPtr) -> RhaiResultOf<Array> {
|
||||||
if array.is_empty() {
|
if array.is_empty() {
|
||||||
return Ok(Array::new());
|
return Ok(Array::new());
|
||||||
@ -692,6 +694,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `filter` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -710,7 +714,7 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// print(y); // prints "[12, 20]"
|
/// print(y); // prints "[12, 20]"
|
||||||
/// ```
|
/// ```
|
||||||
#[rhai_fn(return_raw)]
|
#[rhai_fn(return_raw, pure)]
|
||||||
pub fn filter(ctx: NativeCallContext, array: &mut Array, filter: FnPtr) -> RhaiResultOf<Array> {
|
pub fn filter(ctx: NativeCallContext, array: &mut Array, filter: FnPtr) -> RhaiResultOf<Array> {
|
||||||
if array.is_empty() {
|
if array.is_empty() {
|
||||||
return Ok(Array::new());
|
return Ok(Array::new());
|
||||||
@ -882,6 +886,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `filter` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -922,6 +928,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `filter` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -1011,6 +1019,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `filter` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -1055,6 +1065,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `mapper` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -1087,6 +1099,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `mapper` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -1143,6 +1157,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `filter` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -1185,6 +1201,8 @@ pub mod array_functions {
|
|||||||
///
|
///
|
||||||
/// Array element (mutable) is bound to `this`.
|
/// Array element (mutable) is bound to `this`.
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `filter` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element
|
||||||
@ -1281,9 +1299,11 @@ pub mod array_functions {
|
|||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `result`: accumulated result, initially `()`
|
/// * `result`: accumulated result, initially `()`
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element, or bound to `this` if omitted
|
||||||
/// * `index` _(optional)_: current index in the array
|
/// * `index` _(optional)_: current index in the array
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `reducer` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rhai
|
/// ```rhai
|
||||||
@ -1306,9 +1326,11 @@ pub mod array_functions {
|
|||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `result`: accumulated result, starting with the value of `initial`
|
/// * `result`: accumulated result, starting with the value of `initial`
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element, or bound to `this` if omitted
|
||||||
/// * `index` _(optional)_: current index in the array
|
/// * `index` _(optional)_: current index in the array
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `reducer` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rhai
|
/// ```rhai
|
||||||
@ -1347,9 +1369,11 @@ pub mod array_functions {
|
|||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `result`: accumulated result, initially `()`
|
/// * `result`: accumulated result, initially `()`
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element, or bound to `this` if omitted
|
||||||
/// * `index` _(optional)_: current index in the array
|
/// * `index` _(optional)_: current index in the array
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `reducer` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rhai
|
/// ```rhai
|
||||||
@ -1373,9 +1397,11 @@ pub mod array_functions {
|
|||||||
/// # Function Parameters
|
/// # Function Parameters
|
||||||
///
|
///
|
||||||
/// * `result`: accumulated result, starting with the value of `initial`
|
/// * `result`: accumulated result, starting with the value of `initial`
|
||||||
/// * `element`: copy of array element
|
/// * `element`: copy of array element, or bound to `this` if omitted
|
||||||
/// * `index` _(optional)_: current index in the array
|
/// * `index` _(optional)_: current index in the array
|
||||||
///
|
///
|
||||||
|
/// This method is marked _pure_; the `reducer` function should not mutate array elements.
|
||||||
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rhai
|
/// ```rhai
|
||||||
|
Loading…
Reference in New Issue
Block a user