update document link. rename error.
This commit is contained in:
parent
1d84eea270
commit
638b0d8af2
@ -1,12 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "eval"
|
name = "eval"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
description = "Expression evaluator"
|
description = "Expression evaluator"
|
||||||
keywords = ["expression", "evaluate", "evaluator", "expr"]
|
keywords = ["expression", "evaluate", "evaluator", "expr"]
|
||||||
authors = ["fengcen <fengcen.love@gmail.com>"]
|
authors = ["fengcen <fengcen.love@gmail.com>"]
|
||||||
repository = "https://github.com/fengcen/eval.git"
|
repository = "https://github.com/fengcen/eval.git"
|
||||||
homepage = "https://github.com/fengcen/eval"
|
homepage = "https://github.com/fengcen/eval"
|
||||||
documentation = "https://github.com/fengcen/eval"
|
documentation = "https://docs.rs/eval"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
|
@ -63,9 +63,9 @@ quick_error! {
|
|||||||
UnsupportedTypes(a: String, b: String) {
|
UnsupportedTypes(a: String, b: String) {
|
||||||
display("This two value types are different or do not support mathematical calculations: {}, {}", a, b)
|
display("This two value types are different or do not support mathematical calculations: {}, {}", a, b)
|
||||||
}
|
}
|
||||||
/// Invalid array expression like `1..2..3`
|
/// Invalid range expression like `1..2..3`
|
||||||
InvalidArray(ident: String) {
|
InvalidRange(ident: String) {
|
||||||
display("Invalid array expression: {}", ident)
|
display("Invalid range expression: {}", ident)
|
||||||
}
|
}
|
||||||
/// Custom error.
|
/// Custom error.
|
||||||
Custom(detail: String) {
|
Custom(detail: String) {
|
||||||
|
@ -472,7 +472,7 @@ fn is_range(ident: &str) -> bool {
|
|||||||
fn parse_range(ident: &str) -> Result<Value, Error> {
|
fn parse_range(ident: &str) -> Result<Value, Error> {
|
||||||
let segments = ident.split("..").collect::<Vec<_>>();
|
let segments = ident.split("..").collect::<Vec<_>>();
|
||||||
if segments.len() != 2 {
|
if segments.len() != 2 {
|
||||||
Err(Error::InvalidArray(ident.to_owned()))
|
Err(Error::InvalidRange(ident.to_owned()))
|
||||||
} else {
|
} else {
|
||||||
let start = segments[0].parse::<i64>();
|
let start = segments[0].parse::<i64>();
|
||||||
let end = segments[1].parse::<i64>();
|
let end = segments[1].parse::<i64>();
|
||||||
@ -484,7 +484,7 @@ fn parse_range(ident: &str) -> Result<Value, Error> {
|
|||||||
}
|
}
|
||||||
Ok(to_value(array))
|
Ok(to_value(array))
|
||||||
} else {
|
} else {
|
||||||
Err(Error::InvalidArray(ident.to_owned()))
|
Err(Error::InvalidRange(ident.to_owned()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user