Expand description
Standard functions for the interpreter, and the tools to define new native functions.
§Defining native functions
There are several ways to define new native functions:
Structs§
- All
- Function that checks whether all of array items satisfy the provided predicate.
- Any
- Function that checks whether any of array items satisfy the provided predicate.
- Array
- Function generating an array by mapping its indexes.
- Assert
- Assertion function.
- Assert
Close - Assertion that two values are close to each other.
- Assert
Eq - Equality assertion function.
- Assert
Fails - Assertion that the provided function raises an error. Errors can optionally be matched against a predicate.
- Dbg
std - Acts similarly to the
dbg!macro, outputting the argument(s) to stderr and returning them. If a single argument is provided, it’s returned as-is; otherwise, the arguments are wrapped into a tuple. - Defer
- Allows to define a value recursively, by referencing a value being created.
- Filter
- Filter function that evaluates the provided function on each item of the tuple and retains
only elements for which the function returned
true. - FnWrapper
- Wrapper of a function containing information about its arguments.
- Fold
- Reduce (aka fold) function that reduces the provided tuple to a single value.
- From
Value Error - Error raised when a value cannot be converted to the expected type when using
FnWrapper. - If
iffunction that eagerly evaluates “if” / “else” terms.- Len
- Function returning array / object length.
- Map
- Map function that evaluates the provided function on each item of the tuple.
- Merge
- Function that merges two tuples.
- Push
- Function that appends a value onto a tuple.
- While
- Loop function that evaluates the provided closure while a certain condition is true. Returns the loop state afterwards.
Enums§
- Compare
- Comparator functions on two primitive arguments. All functions use
Arithmeticto determine ordering between the args. - Error
Output - Generic error output encompassing all error types supported by wrapped functions.
- From
Value Error Kind - Error kinds for
FromValueError. - From
Value Error Location - Element of the
FromValueErrorlocation.
Traits§
- Into
Eval Result - Converts type into
Valueor an error. This is used to convert the return type of wrapped functions to the result expected byNativeFn. - TryFrom
Value - Fallible conversion from
Valueto a function argument.
Functions§
- wrap
- Wraps a function enriching it with the information about its arguments.
This is a slightly shorter way to create wrappers compared to calling
FnWrapper::new().
Type Aliases§
- Binary
- Binary function wrapper.
- Quaternary
- Quaternary function wrapper.
- Ternary
- Ternary function wrapper.
- Unary
- Unary function wrapper.