pub fn int(
state: &State<'_, '_>,
value: &Value,
default: Option<Value>,
base: Option<u32>,
kwargs: Kwargs,
) -> Result<Value, Error>Expand description
Converts a value into an integer.
Strings are parsed in the given base (10 by default). For bases 2, 8
and 16 the string may carry a 0b, 0o or 0x prefix. If the value
cannot be converted and a default is given, the default is returned
instead of an error. none converts to the default or 0.
{{ "42"|int == 42 }} -> true
{{ "0x1f"|int(base=16) }} -> 31
{{ "n/a"|int(default=0) }} -> 0