Commit Graph

106 Commits

Author SHA1 Message Date
Sebastian Schmidt
9fc86a934f Change context trait.
Instead of one catchall trait for contexts, there are now several:

 * `Context` is now a "use-only" context, allowing only to retrieve variable names and call functions.
 * `ContextWithMutableVariables` also allows to mutate variables.
 * `ContextWithMutableFunctions` also allows to mutate functions. However this is not used anywhere at the moment. It will come in handy when the evalexpr language gets a function definition feature.
 * `GetFunctionContext` also allows to retrieve functions as `Function` type. This is uncommented at the moment, as it does not have any use in the crate as of now, and likely also not with planned future features.

 Additionally, this commit makes functions generic over the context type, as opposed to having a dynamic reference to a context type.

Relates to #73
2021-05-28 10:27:32 +03:00
Sebastian Schmidt
862bfae920 Add #![forbid(unsafe_code)]
Closes #70
2021-05-28 09:30:26 +03:00
Sebastian Schmidt
6163972382 Reformat code examples to reduce horizontal scrolling 2019-08-30 10:07:48 +03:00
Sebastian Schmidt
b8d7344cc5 Improve documentation 2019-08-30 10:03:31 +03:00
Sebastian Schmidt
4571f3a578 Update aggregation operator documentation
Relates to #44
2019-08-30 09:16:43 +03:00
Sebastian Schmidt
2ec3dc74c1 Make operator enum public
This is required for better error messages.

Relates to #60
2019-08-29 16:28:43 +03:00
Sebastian Schmidt
d8eed924cc Add documentation about operator assignments 2019-08-29 13:21:54 +03:00
Sebastian Schmidt
b9c4b34a2f Make builtin len support tuples
Implements #41
2019-08-29 11:10:54 +03:00
Sebastian Schmidt
95ba26a2cd Fix doctest for context creation macro
Relates to #48
2019-08-29 10:50:32 +03:00
Sebastian Schmidt
60b6cdf180 Add documentation about context creation macro
Implements #48
2019-08-29 10:47:58 +03:00
Sebastian Schmidt
3670bcaf63 Add comments to code in docs 2019-08-29 10:33:12 +03:00
Sebastian Schmidt
88559d5493 Add some information about contexts to docs 2019-08-29 10:30:55 +03:00
Sebastian Schmidt
2399df16a1 Run rustfmt 2019-08-29 10:02:05 +03:00
Sebastian Schmidt
0c5d032b37 Merge remote-tracking branch 'origin/master' 2019-08-29 08:57:07 +03:00
Sebastian Schmidt
2ee1f8f62c Deny missing docs 2019-08-29 08:56:58 +03:00
Sebastian Schmidt
e6c19077b6 Implement value decomposition API
* Removed expect_... methods and replaced them with .as_...() methods. This removes the need to import the free-standing methods every time and makes the code cleaner.
 * Changed all the examples appropriately.

Implements #53
2019-08-29 08:56:49 +03:00
Atul Bhosale
311c70a823
Update crate for Rust 2018 using 'cargo fix --edition' 2019-06-06 23:23:30 +05:30
Sebastian Schmidt
6f533ca925 Merge branch '52_remove_automatic_function_argument_decomposition' 2019-05-04 13:53:47 +02:00
Sebastian Schmidt
f6c2ef2fb6 Remove automatic function argument decomposition
Relates to #52
2019-05-04 13:43:29 +02:00
ISibboI
b85e8e1b75
Merge pull request #49 from lovasoa/master
Use the new context macro in the README examples
2019-04-26 17:36:15 +02:00
Sebastian Schmidt
bc826e5bf2 Use context_map macro in lib.rs documentation as well
Should have used `cargo sync-readme` to begin with, but that was not
documented at the time of this pull request.
2019-04-26 17:33:59 +02:00
Sebastian Schmidt
8432058052 Execute serde doctest only if serde_support is enabled
Relates to #50
2019-04-24 18:36:30 +02:00
Sebastian Schmidt
83386c03d3 Improve documentation of builtin functions
Relates to #38
2019-04-13 18:12:33 +02:00
ISibboI
2f7d1c2dfe
Merge pull request #38 from bittrance/string-operators
String operators and builtin functions
2019-04-13 18:02:24 +02:00
Quest
be54931f76 Builtin string functions - downcase, len, match(regex), replace(regex), trim, upcase. New dependency regex. 2019-04-12 23:35:33 +02:00
Sebastian Schmidt
15313f7341 Update target release 2019-04-12 18:45:46 +02:00
Sebastian Schmidt
67d68cd974 Add string constants
* Implement string parsing in tokenizer
 * Implement escape sequences `\"` and `\\`
 * Document changes
 * Update change log

Relates to #35
2019-03-30 11:54:26 +01:00
Sebastian Schmidt
17bedddb11 Add serde support for HashMapContext
Relates to #33
2019-03-28 15:40:02 +01:00
Sebastian Schmidt
606c358cc9 Make operator table one-columned 2019-03-28 15:01:20 +01:00
Sebastian Schmidt
aeb584edca Add quickstart documentation with chain and assign features 2019-03-28 12:09:46 +01:00
Sebastian Schmidt
44152533c3 Set release target to major 2019-03-28 11:49:06 +01:00
Sebastian Schmidt
ab49531306 Document chain operator
Relates to #26
2019-03-28 11:46:56 +01:00
Sebastian Schmidt
83269068a2 Add the assignment operator
Relates to #25
2019-03-28 11:12:47 +01:00
Sebastian Schmidt
13420ed745 Document the empty type
Relates to #28
2019-03-28 10:38:16 +01:00
Sebastian Schmidt
5bc4bcb702 Add crate level shortcut evaluations for Value::Empty
Relates to #28
2019-03-28 10:32:42 +01:00
Sebastian Schmidt
7d36ebe8df Add Node shortcut evaluations for Value::Empty
Relates to #28
2019-03-28 10:26:49 +01:00
Sebastian Schmidt
88ab1e1987 Add Value::Empty and ValueType::Empty
Relates to #28
2019-03-28 09:56:44 +01:00
Sebastian Schmidt
e266f4fc0d Merge ContextMut with Context and add eval_<type>_with_context_mut methods
Trait objects of `ContextMut` cannot be converted into `Context`, even though `ContextMut` requires `Context`.

Relates to #30
2019-03-28 09:22:48 +01:00
Sebastian Schmidt
0acbcd8958 Format code 2019-03-28 08:44:04 +01:00
Sebastian Schmidt
ece22c6b35 Fix typo 2019-03-28 08:41:46 +01:00
Sebastian Schmidt
83451a9028 Use as_number in quickstart example
Otherwise the example would not allow mixed float and int arguments.
2019-03-28 08:41:16 +01:00
Sebastian Schmidt
6f31d69d7d Prepare 2.0.0 release 2019-03-27 19:14:24 +01:00
Sebastian Schmidt
d77fa15864 Use EvalexprResult<T> everywhere
Relates to #31
2019-03-27 19:09:58 +01:00
Sebastian Schmidt
24ca11e52a Document how to enable serde feature flag
Relates to #21
2019-03-27 18:35:00 +01:00
Sebastian Schmidt
9283d5412f Rename Context to ContextMut and Configuration to Context
Get rid of two different words for the same concept.

Relates to #22
2019-03-27 18:09:33 +01:00
Sebastian Schmidt
7decb7c895 Make ValueType public 2019-03-27 17:55:05 +01:00
Sebastian Schmidt
44041b03db Make TupleType alias public 2019-03-27 17:53:48 +01:00
Sebastian Schmidt
3da6019dae Add Context trait
* Rename `HashMapConfiguration` to `HashMapContext`
 * Rename `EmptyConfiguration` to `EmptyContext`
 * Implement `Context` for both predefined contexts
 * Update tests and doctests

Relates to #22
2019-03-27 17:45:06 +01:00
Sebastian Schmidt
fd879193b6 Rename Error to EvalexprError and add EvalexprResult
Relates to #27
2019-03-27 16:33:46 +01:00
Sebastian Schmidt
8a49bf9c11 Get rid of some unwraps
Relates to #14
2019-03-27 16:16:40 +01:00