Calculates the size of either the target, or the provided args depending on how the function is called. If called as a method, the target will be used. If called as a function, the first argument will be used. The following [`Value`] variants are supported: [`Value::List`] [`Value::Map`] [`Value::String`] [`Value::Bytes`] # Examples ```skip size([1, 2, 3]) == 3 ``` ```skip 'foobar'.size() == 6
(ftx: &FunctionContext, This(this): This<Value>)
| 74 | /// 'foobar'.size() == 6 |
| 75 | /// ``` |
| 76 | pub fn size(ftx: &FunctionContext, This(this): This<Value>) -> Result<i64> { |
| 77 | let size = match this { |
| 78 | Value::List(l) => l.len(), |
| 79 | Value::Map(m) => m.map.len(), |
| 80 | Value::String(s) => s.len(), |
| 81 | value => return Err(ftx.error(format!("cannot determine the size of {value:?}"))), |
| 82 | }; |
| 83 | Ok(size as i64) |
| 84 | } |
| 85 | |
| 86 | /// Returns true if the target contains the provided argument. The actual behavior |
| 87 | /// depends mainly on the type of the target. |