merge: add as_slice() method

This was already possible using `merge.iter().as_slice()`, but I think
this is cleaner.
This commit is contained in:
Scott Taylor 2024-11-17 08:00:04 -06:00 committed by Scott Taylor
parent 54c453ba8d
commit ec6220d51f

View file

@ -339,6 +339,13 @@ impl<T> Merge<T> {
self.values.resize(num_sides * 2 - 1, value.clone());
}
/// Returns a slice containing the terms. The items will alternate between
/// positive and negative terms, starting with positive (since there's one
/// more of those).
pub fn as_slice(&self) -> &[T] {
&self.values
}
/// Returns an iterator over references to the terms. The items will
/// alternate between positive and negative terms, starting with
/// positive (since there's one more of those).