Implement contains operator functionality
This commit is contained in:
parent
bf9ceaf693
commit
9ae2cc7cd1
1 changed files with 22 additions and 4 deletions
|
@ -237,8 +237,17 @@ pub fn more_than_or_equal(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
||||||
|
|
||||||
pub fn contain(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
pub fn contain(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
||||||
match a {
|
match a {
|
||||||
Literal::Array(v) => todo!(),
|
Literal::Array(v) => match v.value.iter().any(|x| match x {
|
||||||
Literal::Strand(v) => todo!(),
|
Value::Literal(v) => equal(v, b).is_ok(),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}) {
|
||||||
|
true => Ok(Literal::True),
|
||||||
|
false => Ok(Literal::False),
|
||||||
|
},
|
||||||
|
Literal::Strand(v) => match b {
|
||||||
|
Literal::Strand(w) => Ok(Literal::from(v.value.contains(w.value.as_str()) == true)),
|
||||||
|
_ => Ok(Literal::from(v.value.contains(&b.as_strand().value.as_str()) == true)),
|
||||||
|
},
|
||||||
Literal::Polygon(v) => todo!(),
|
Literal::Polygon(v) => todo!(),
|
||||||
_ => Ok(Literal::False),
|
_ => Ok(Literal::False),
|
||||||
}
|
}
|
||||||
|
@ -246,8 +255,17 @@ pub fn contain(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
||||||
|
|
||||||
pub fn not_contain(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
pub fn not_contain(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
||||||
match a {
|
match a {
|
||||||
Literal::Array(v) => todo!(),
|
Literal::Array(v) => match v.value.iter().any(|x| match x {
|
||||||
Literal::Strand(v) => todo!(),
|
Value::Literal(v) => equal(v, b).is_ok(),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}) {
|
||||||
|
true => Ok(Literal::False),
|
||||||
|
false => Ok(Literal::True),
|
||||||
|
},
|
||||||
|
Literal::Strand(v) => match b {
|
||||||
|
Literal::Strand(w) => Ok(Literal::from(v.value.contains(w.value.as_str()) == false)),
|
||||||
|
_ => Ok(Literal::from(v.value.contains(&b.as_strand().value.as_str()) == false)),
|
||||||
|
},
|
||||||
Literal::Polygon(v) => todo!(),
|
Literal::Polygon(v) => todo!(),
|
||||||
_ => Ok(Literal::False),
|
_ => Ok(Literal::False),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue