oneline_template/functions/int/to_string.rs
1use crate::function_executor::*;
2
3/// Function: `int:to_string`
4///
5/// Input: `int`
6///
7/// Returns `string`
8pub struct ToString;
9
10impl FunctionExecutor for ToString {
11 fn schema(&self) -> FunctionSchema {
12 FunctionSchema::new("int:to_string")
13 }
14
15 fn call(&self, value: Value, _arguments: &[Value]) -> Result<Value, FunctionError> {
16 let value = value.as_int()?;
17 let value = format!("{}", value);
18 let value = Value::String(value);
19 return Ok(value);
20 }
21}