cherries-0.3.2 doesn't have any documentation.
Cherries the expression logging library
Cherries is a crate that does expression logging as json structure.
Usage
cherries requires rustc 1.37.0 or later. Add this to your Cargo.toml:
cherries = "0.3.1"
Labeling
You can label to leaf with builder or rename with labeled method.
extern crate cherries;
use ;
Validation
Validation utilities are in module cherries::validate.
- Validate: Trait that provides extension method
validatetoCherry<T>. - ValidateChain: Struct that allows to chain
validateand providesinto_result. - Error: Information struct for validation errors.
extern crate cherries;
use ;
use ;
Get json string
You can get expression tree with json structure using Cherries::to_json().
extern crate cherries;
use ;
use ;
Output:
{
"label":"(mul)",
"value":15,
"unit":"dimensionless",
"subexpr":[
{
"label":"(add)",
"value":5,
"unit":"dimensionless",
"subexpr":[
{
"label":"a",
"value":2,
"unit":"dimensionless"
},
{
"label":"b",
"value":3,
"unit":"dimensionless"
}
]
},
{
"label":"(sub)",
"value":3,
"unit":"dimensionless",
"subexpr":[
{
"label":"c",
"value":4,
"unit":"dimensionless"
},
{
"label":"d",
"value":1,
"unit":"dimensionless"
}
]
}
]
}
Mapping
For example, show you how to use cherries with uom crate (units of measurement).
Let's applying method floor with turbofish using map.
extern crate cherries;
use ;
use ;
use *;
use ;
Output:
{
"label":"floor",
"value":2,
"unit":"m^1",
"subexpr":[
{
"label":"x",
"value":2.1,
"unit":"m^1"
}
]
}
Serialize/Deserialize (v0.3.0~)
Cherry<T> where T: serde::Serialize + .../Cherry<T> where T: serde::Deserialize + ...
are implemented serde::Serialize and serde::Deserialize.
License
Licensed under MIT LICENSE.