MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / is_truthy

Function is_truthy

nodedb-query/src/value_ops.rs:67–76  ·  view source on GitHub ↗

Check if a Value is truthy (for boolean contexts). - `true` → true, `false` → false - `Null` → false - Numbers: non-zero → true - Strings: non-empty → true - Arrays/Objects: always true

(v: &Value)

Source from the content-addressed store, hash-verified

65/// - Strings: non-empty → true
66/// - Arrays/Objects: always true
67pub fn is_truthy(v: &Value) -> bool {
68 match v {
69 Value::Bool(b) => *b,
70 Value::Null => false,
71 Value::Integer(i) => *i != 0,
72 Value::Float(f) => *f != 0.0,
73 Value::String(s) => !s.is_empty(),
74 _ => true,
75 }
76}
77
78/// Convert a Value to a display string.
79///

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected