Cherries the expression logging library
Cherries is a crate that does expression logging as json structure.
Usage
uom requires rustc 1.37.0 or later. Add this to your Cargo.toml:
cherries = "0.1.0"
Labeling
You can label to leaf with builder or rename with label method.
extern crate cherries;
use ;
Validation
extern crate cherries;
use ;
use ;
Get json string
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"
}
]
}
License
Licensed under MIT LICENSE.