parent
03a30205e2
commit
4571f3a578
22
README.md
22
README.md
@ -166,14 +166,30 @@ Supported unary operators:
|
|||||||
|
|
||||||
#### The Aggregation Operator
|
#### The Aggregation Operator
|
||||||
|
|
||||||
The aggregation operator aggregates two values into a tuple.
|
The aggregation operator aggregates a set of values into a tuple.
|
||||||
If one of the values is a tuple already, the resulting tuple will be flattened.
|
A tuple can contain arbitrary values, it is not restricted to a single type.
|
||||||
|
The operator is n-ary, so it supports creating tuples longer than length two.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use evalexpr::*;
|
use evalexpr::*;
|
||||||
|
|
||||||
assert_eq!(eval("1, 2, 3"), Ok(Value::from(vec![Value::from(1), Value::from(2), Value::from(3)])));
|
assert_eq!(eval("1, \"b\", 3"), Ok(Value::from(vec![Value::from(1), Value::from("b"), Value::from(3)])));
|
||||||
|
```
|
||||||
|
|
||||||
|
To create nested tuples, use parentheses:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use evalexpr::*;
|
||||||
|
|
||||||
|
assert_eq!(eval("1, 2, (true, \"b\")"), Ok(Value::from(vec![
|
||||||
|
Value::from(1),
|
||||||
|
Value::from(2),
|
||||||
|
Value::from(vec![
|
||||||
|
Value::from(true),
|
||||||
|
Value::from("b")
|
||||||
|
])
|
||||||
|
])));
|
||||||
```
|
```
|
||||||
|
|
||||||
#### The Assignment Operator
|
#### The Assignment Operator
|
||||||
|
22
src/lib.rs
22
src/lib.rs
@ -153,14 +153,30 @@
|
|||||||
//!
|
//!
|
||||||
//! #### The Aggregation Operator
|
//! #### The Aggregation Operator
|
||||||
//!
|
//!
|
||||||
//! The aggregation operator aggregates two values into a tuple.
|
//! The aggregation operator aggregates a set of values into a tuple.
|
||||||
//! If one of the values is a tuple already, the resulting tuple will be flattened.
|
//! A tuple can contain arbitrary values, it is not restricted to a single type.
|
||||||
|
//! The operator is n-ary, so it supports creating tuples longer than length two.
|
||||||
//! Example:
|
//! Example:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use evalexpr::*;
|
//! use evalexpr::*;
|
||||||
//!
|
//!
|
||||||
//! assert_eq!(eval("1, 2, 3"), Ok(Value::from(vec![Value::from(1), Value::from(2), Value::from(3)])));
|
//! assert_eq!(eval("1, \"b\", 3"), Ok(Value::from(vec![Value::from(1), Value::from("b"), Value::from(3)])));
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! To create nested tuples, use parentheses:
|
||||||
|
//!
|
||||||
|
//! ```rust
|
||||||
|
//! use evalexpr::*;
|
||||||
|
//!
|
||||||
|
//! assert_eq!(eval("1, 2, (true, \"b\")"), Ok(Value::from(vec![
|
||||||
|
//! Value::from(1),
|
||||||
|
//! Value::from(2),
|
||||||
|
//! Value::from(vec![
|
||||||
|
//! Value::from(true),
|
||||||
|
//! Value::from("b")
|
||||||
|
//! ])
|
||||||
|
//! ])));
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! #### The Assignment Operator
|
//! #### The Assignment Operator
|
||||||
|
Loading…
Reference in New Issue
Block a user