Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/variable_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ impl<T, N: Unsigned> VariableList<T, N> {
}
}

/// Creates a full list with the given element repeated.
pub fn repeat_full(elem: T) -> Self
where
T: Clone,
{
Self {
vec: vec![elem; N::to_usize()],
_phantom: PhantomData,
}
}

/// Returns the number of values presently in `self`.
pub fn len(&self) -> usize {
self.vec.len()
Expand Down Expand Up @@ -386,6 +397,13 @@ mod test {
assert!(fixed.is_ok());
}

#[test]
fn repeat_full() {
let manual_list = VariableList::<u64, U5>::new(vec![42; 5]).unwrap();
let repeat_list = VariableList::<u64, U5>::repeat_full(42);
assert_eq!(manual_list, repeat_list);
}

#[test]
fn indexing() {
let vec = vec![1, 2];
Expand Down
Loading