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

Method get

cel/src/objects.rs:67–83  ·  view source on GitHub ↗

Returns a reference to the value corresponding to the key. Implicitly converts between int and uint keys.

(&self, key: &(dyn AsKeyRef + '_))

Source from the content-addressed store, hash-verified

65 /// Returns a reference to the value corresponding to the key. Implicitly converts between int
66 /// and uint keys.
67 pub fn get(&self, key: &(dyn AsKeyRef + '_)) -> Option<&Value> {
68 self.map.get(key).or_else(|| {
69 // Also check keys that are cross type comparable.
70 let keyref = key.as_keyref();
71 match keyref {
72 KeyRef::Int(k) => {
73 let converted = u64::try_from(k).ok()?;
74 self.map.get(&Key::Uint(converted))
75 }
76 KeyRef::Uint(k) => {
77 let converted = i64::try_from(k).ok()?;
78 self.map.get(&Key::Int(converted))
79 }
80 _ => None,
81 }
82 })
83 }
84}
85
86#[derive(Debug, Eq, PartialEq, Hash, Ord, Clone, PartialOrd)]

Callers 1

resolve_valMethod · 0.45

Calls 2

IntClass · 0.85
as_keyrefMethod · 0.45

Tested by

no test coverage detected