[][src]Function zamm_yin::graph::value_wrappers::unwrap_value

pub fn unwrap_value<'a, T: 'a>(
    wrapper: Option<Rc<dyn KBValue + 'a>>
) -> Option<Rc<T>>

Helper function for unwrapping values contained inside a WeakValue.

There are three layers of options here:

  1. The option of whether or not there is a value associated with this KB node. Necessary because not every node has a value to it.
  2. The option of whether or not the value associated with this KB node is contained inside a WeakValue, as opposed to some other wrapper. If this fails, this will try a StrongValue next. This should always succeed if the code is correct.
  3. The option of whether the value referred to here still exists. Since a WeakValue refers to values outside of the KB that might stop existing at any given time, this is not guaranteed to return a value even if there was originally one associated with the node.

This function encapsulates all of the above into one simpler return value.