MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / as_integer

Function as_integer

flow-plugins/src/utils/args_parser.rs:4–16  ·  view source on GitHub ↗
(map: &Table, key: &str, default: T)

Source from the content-addressed store, hash-verified

2use toml::value::*;
3
4pub fn as_integer<T>(map: &Table, key: &str, default: T) -> T
5where
6 T: 'static + Copy,
7 i64: AsPrimitive<T>,
8{
9 map.get(key)
10 .map(|x| {
11 x.as_integer()
12 .unwrap_or_else(|| panic!("Invalid arguments in field {}", key))
13 .as_()
14 })
15 .unwrap_or(default)
16}
17
18pub fn as_bool(map: &Table, key: &str, default: bool) -> bool {
19 map.get(key)

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected