Skip to main content

try_lookup_int

Function try_lookup_int 

Source
pub fn try_lookup_int(key: &str) -> Option<i64>
Expand description

lookup_int variant that never panics on a live mutable borrow.

Returns None when STATE is currently mutably borrowed (contention), Some(0) when the key is absent/non-integer (matching lookup_int’s default), else Some(value).

This exists for the Error!/Warn! reporting path: an error can legitimately be raised from inside a state_mut() scope (e.g. push_value’s BUG branch, or any constructor after_digest holding the borrow). A plain borrow() there panics “RefCell already mutably borrowed”, aborting the whole conversion (FATAL_panic; crashed tikz-cd 2001.08973 via push_value("QED@stack", …)). The error reporter must be re-entrancy-safe regardless of what borrows are held — degrade to “unknown” on contention rather than crash.