Struct zerovec::varzerovec::VarZeroVecULE [−][src]
#[repr(transparent)]pub struct VarZeroVecULE<T: ?Sized> { /* fields omitted */ }
Expand description
A VarULE version of VarZeroVec allowing for VarZeroVecs to be nested indefinitely
use zerovec::VarZeroVec;
use zerovec::ZeroVec;
use zerovec::varzerovec::VarZeroVecULE;
use zerovec::ule::*;
let strings_1: Vec<String> = vec!["foo".into(), "bar".into(), "baz".into()];
let strings_2: Vec<String> = vec!["twelve".into(), "seventeen".into(), "forty two".into()];
let strings_3: Vec<String> = vec!["我".into(), "喜歡".into(), "烏龍茶".into()];
let strings_4: Vec<String> = vec!["w".into(), "ω".into(), "文".into(), "𑄃".into()];
let strings_12 = vec![strings_1.clone(), strings_2.clone()];
let strings_34 = vec![strings_3.clone(), strings_4.clone()];
let all_strings = vec![strings_12, strings_34];
let vzv_1: VarZeroVec<str> = VarZeroVec::from(&*strings_1);
let vzv_2: VarZeroVec<str> = VarZeroVec::from(&*strings_2);
let vzv_3: VarZeroVec<str> = VarZeroVec::from(&*strings_3);
let vzv_4: VarZeroVec<str> = VarZeroVec::from(&*strings_4);
let vzv_12 = VarZeroVec::from(&[vzv_1.as_ule(), vzv_2.as_ule()] as &[_]);
let vzv_34 = VarZeroVec::from(&[vzv_3.as_ule(), vzv_4.as_ule()] as &[_]);
let vzv_all = VarZeroVec::from(&[vzv_12.as_ule(), vzv_34.as_ule()] as &[_]);
let reconstructed: Vec<Vec<Vec<String>>> = vzv_all.iter()
.map(|v: &VarZeroVecULE<VarZeroVecULE<str>>| {
v.iter().map(|x: &VarZeroVecULE<_>| x.as_varzerovec().iter().map(|s| s.to_owned()).collect::<Vec<String>>())
.collect::<Vec<_>>()
}).collect::<Vec<_>>();
assert_eq!(reconstructed, all_strings);
let bytes = vzv_all.get_encoded_slice();
let vzv_from_bytes: VarZeroVec<VarZeroVecULE<VarZeroVecULE<str>>> = VarZeroVec::parse_byte_slice(bytes).unwrap();
assert_eq!(vzv_from_bytes, vzv_all);
Implementations
Obtain an iterator over VarZeroVecULE’s elements
Get one of VarZeroVecULE’s elements, returning None if the index is out of bounds
Get this VarZeroVecULE
as a borrowed VarZeroVec
If you wish to repeatedly call methods on this VarZeroVecULE
,
it is more efficient to perform this conversion first
Binary searches a sorted VarZeroVecULE<T>
for the given element. For more information, see
the primitive function binary_search
.
Trait Implementations
Performs the conversion.
impl<T> PartialEq<VarZeroVecULE<T>> for VarZeroVecULE<T> where
T: VarULE,
T: ?Sized,
T: PartialEq,
impl<T> PartialEq<VarZeroVecULE<T>> for VarZeroVecULE<T> where
T: VarULE,
T: ?Sized,
T: PartialEq,
type Error = ParseErrorFor<T>
type Error = ParseErrorFor<T>
The error that occurs if a byte array is not valid for this ULE.
Validates a byte slice, &[u8]
. Read more
Takes a byte slice, &[u8]
, and return it as &Self
with the same lifetime, assuming
that this byte slice has previously been run through Self::parse_byte_slice()
with
success. Read more
Parses a byte slice, &[u8]
, and return it as &Self
with the same lifetime. Read more