pub trait SeqTrait<T: Clone>:
Index<usize, Output = T>
+ IndexMut<usize, Output = T>
+ Sized {
// Required methods
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;
// Provided methods
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§
fn len(&self) -> usize
fn iter(&self) -> Iter<'_, T>
fn create(len: usize) -> Self
Sourcefn update_slice<A: SeqTrait<T>>(
self,
start_out: usize,
v: &A,
start_in: usize,
len: usize,
) -> Self
fn update_slice<A: SeqTrait<T>>( self, start_out: usize, v: &A, start_in: usize, len: usize, ) -> Self
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§
Sourcefn update<A: SeqTrait<T>>(self, start: usize, v: &A) -> Self
fn update<A: SeqTrait<T>>(self, start: usize, v: &A) -> Self
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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.