vello_encoding/
monoid.rs

1// Copyright 2022 the Vello Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4/// Interface for a monoid. The default value must be the identity of
5/// the monoid.
6pub trait Monoid: Default {
7    /// The source value for constructing the monoid.
8    type SourceValue;
9
10    /// Creates a monoid from a given value.
11    fn new(value: Self::SourceValue) -> Self;
12
13    /// Combines two monoids. This operation must be associative.
14    #[must_use]
15    fn combine(&self, other: &Self) -> Self;
16}