MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / access_vector

Method access_vector

ciphercore-base/src/data_values.rs:1078–1087  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 15

test_tupleFunction · 0.80
test_named_tupleFunction · 0.80
test_vectorFunction · 0.80
test_emptyFunction · 0.80
is_equalMethod · 0.80
secret_share_revealMethod · 0.80
generalized_subtractFunction · 0.80
generalized_addFunction · 0.80
test_secret_sharingFunction · 0.80
evaluateFunction · 0.80
evaluateFunction · 0.80
check_outputFunction · 0.80

Calls

no outgoing calls

Tested by 6

test_tupleFunction · 0.64
test_named_tupleFunction · 0.64
test_vectorFunction · 0.64
test_emptyFunction · 0.64
test_secret_sharingFunction · 0.64
test_secret_sharingFunction · 0.64