Trait hacspec_lib::prelude::SeqTrait
source · [−]pub trait SeqTrait<T: Clone>: Index<usize, Output = T> + IndexMut<usize, Output = T> + Sized {
fn len(&self) -> usize;
fn iter(&self) -> Iter<'_, T>;
fn create(len: usize) -> Self;
fn update_slice<A: SeqTrait<T>>(
self,
start_out: usize,
v: &A,
start_in: usize,
len: usize
) -> Self;
fn update<A: SeqTrait<T>>(self, start: usize, v: &A) -> Self { ... }
fn update_start<A: SeqTrait<T>>(self, v: &A) -> Self { ... }
}
Expand description
Common trait for all byte arrays and sequences.
Required Methods
Update this sequence with l
elements of v
, starting at start_in
,
at start_out
.
Examples
use hacspec_lib::*;
let mut s = Seq::<u8>::new(5);
let tmp = Seq::<u8>::from_native_slice(&[2, 3]);
s = s.update_slice(2, &tmp, 1, 1);
// assert_eq!(s, Seq::<u8>::from_array(&[0, 0, 3, 0, 0]));
Provided Methods
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Update this sequence with v
starting at start
.
Examples
use hacspec_lib::*;
let mut s = Seq::<u8>::new(5);
let tmp = Seq::<u8>::from_native_slice(&[2, 3]);
s = s.update(2, &tmp);
// assert_eq!(s, Seq::<u8>::from_array(&[0, 0, 2, 3, 0]));
fn update_start<A: SeqTrait<T>>(self, v: &A) -> Self
fn update_start<A: SeqTrait<T>>(self, v: &A) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.