Runs a given closure if `self` corresponds to a vector of values, and panic otherwise. # Arguments `f` - a closure, that takes a reference to a vector of values, to run # Returns Return value of `f` # Panics Panics if `self` is a byte vector. # Examples ``` # use ciphercore_base::data_values::Value; let v = Value::from_vector(vec![]); v.access_vector(|vector| { assert!(vector.is_empty());
(&self, f: F)
| 1076 | /// }).unwrap(); |
| 1077 | /// ``` |
| 1078 | pub fn access_vector<F, R>(&self, f: F) -> Result<R> |
| 1079 | where |
| 1080 | F: FnOnce(&Vec<Value>) -> Result<R>, |
| 1081 | { |
| 1082 | if let ValueBody::Vector(v) = self.body.as_ref() { |
| 1083 | f(v) |
| 1084 | } else { |
| 1085 | panic!("Value::access_vector() on an invalid Value"); |
| 1086 | } |
| 1087 | } |
| 1088 | |
| 1089 | /// Runs one closure if `self` corresponds to a byte vector, |
| 1090 | /// and another closure if `self` corresponds to a vector of values. |
no outgoing calls