From ec6220d51f033325ac19a3e768e22c2b74d985bc Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 17 Nov 2024 08:00:04 -0600 Subject: [PATCH] merge: add `as_slice()` method This was already possible using `merge.iter().as_slice()`, but I think this is cleaner. --- lib/src/merge.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/src/merge.rs b/lib/src/merge.rs index 7a3e00645..3ed104602 100644 --- a/lib/src/merge.rs +++ b/lib/src/merge.rs @@ -339,6 +339,13 @@ impl Merge { 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).