Function cel_interpreter::functions::contains

source ·
pub fn contains(This: This<Value>, arg: Value) -> Result<Value, ExecutionError>
Expand description

Returns true if the target contains the provided argument. The actual behavior depends mainly on the type of the target.

The following Value variants are supported:

  • Value::List - Returns true if the list contains the provided value.
  • Value::Map - Returns true if the map contains the provided key.
  • Value::String - Returns true if the string contains the provided substring.
  • Value::Bytes - Returns true if the bytes contain the provided byte.

§Example

§List

[1, 2, 3].contains(1) == true

§Map

{"a": 1, "b": 2, "c": 3}.contains("a") == true

§String

"abc".contains("b") == true

§Bytes

b"abc".contains(b"c") == true