haar_lib/algebra/
update_fold.rs1pub use crate::algebra::{action::Action, first_last::Last, traits::*};
3use std::fmt::Debug;
4use std::marker::PhantomData;
5
6#[derive(Copy, Clone, Default, Debug, PartialEq, Eq)]
11pub struct UpdateFold<M: Monoid>(PhantomData<M>);
12
13impl<M> Action for UpdateFold<M>
14where
15 M: Monoid + Clone,
16{
17 type Output = M;
18 type Lazy = Last<M>;
19
20 fn convert(value: Self::Output, lazy: Self::Lazy, len: usize) -> Self::Output {
21 match lazy.0 {
22 Some(m) => m.times(len as u64),
23 _ => value,
24 }
25 }
26}