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

Method to_vector

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

Converts `self` to a vector of values or return an error if `self` is a byte vector. # Returns Extracted vector of values # Examples ``` # use ciphercore_base::data_values::Value; let v = Value::from_vector( vec![ Value::from_vector(vec![]), Value::from_bytes(vec![1, 2, 3])]); let vv = v.to_vector().unwrap(); assert_eq!(vv.len(), 2); vv[0].access_vector(|v| { assert_eq!(*v, Vec:: ::new()

(&self)

Source from the content-addressed store, hash-verified

672 /// }).unwrap();
673 /// ```
674 pub fn to_vector(&self) -> Result<Vec<Value>> {
675 if let ValueBody::Vector(contents) = self.body.as_ref() {
676 Ok(contents.clone())
677 } else {
678 Err(runtime_error!("Not a vector!"))
679 }
680 }
681
682 /// Converts `self` to a flattened array if it is a byte vector, then cast the array entries to `u8`.
683 ///

Callers 11

test_prf_output_valueFunction · 0.45
test_deep_cloneFunction · 0.45
get_helperFunction · 0.45
get_sub_vector_helperFunction · 0.45
insert_helperFunction · 0.45
push_helperFunction · 0.45
extend_helperFunction · 0.45
remove_helperFunction · 0.45
evaluate_call_iterateMethod · 0.45

Calls 1

cloneMethod · 0.80

Tested by 3

test_prf_output_valueFunction · 0.36
test_deep_cloneFunction · 0.36