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

Function parse_unit

cel/src/duration.rs:78–87  ·  view source on GitHub ↗
(i: &str)

Source from the content-addressed store, hash-verified

76}
77
78fn parse_unit(i: &str) -> IResult<&str, Unit> {
79 alt((
80 map(tag("ms"), |_| Unit::Millisecond),
81 map(tag("us"), |_| Unit::Microsecond),
82 map(tag("ns"), |_| Unit::Nanosecond),
83 map(char('h'), |_| Unit::Hour),
84 map(char('m'), |_| Unit::Minute),
85 map(char('s'), |_| Unit::Second),
86 ))(i)
87}
88
89fn to_duration(num: f64, unit: Unit) -> Duration {
90 Duration::nanoseconds((num * unit.nanos() as f64).trunc() as i64)

Callers 1

parse_number_unitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected