MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / double

Function double

cel/src/functions.rs:163–174  ·  view source on GitHub ↗

Performs a type conversion on the target.

(ftx: &FunctionContext, This(this): This<Value>)

Source from the content-addressed store, hash-verified

161
162// Performs a type conversion on the target.
163pub fn double(ftx: &FunctionContext, This(this): This<Value>) -> Result<Value> {
164 Ok(match this {
165 Value::String(v) => v
166 .parse::<f64>()
167 .map(Value::Float)
168 .map_err(|e| ftx.error(format!("string parse error: {e}")))?,
169 Value::Float(v) => Value::Float(v),
170 Value::Int(v) => Value::Float(v as f64),
171 Value::UInt(v) => Value::Float(v as f64),
172 v => return Err(ftx.error(format!("cannot convert {v:?} to double"))),
173 })
174}
175
176// Performs a type conversion on the target.
177pub fn uint(ftx: &FunctionContext, This(this): This<Value>) -> Result<Value> {

Callers 1

parse_number_unitFunction · 0.70

Calls 2

mapMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected