2023-04-14 12:00:27 -07:00
|
|
|
// Copyright 2022 The Vello authors
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
2023-01-06 16:52:41 -05:00
|
|
|
|
2023-01-08 17:10:05 -05:00
|
|
|
/// Interface for a monoid. The default value must be the identity of
|
|
|
|
/// the monoid.
|
|
|
|
pub trait Monoid: Default {
|
|
|
|
/// The source value for constructing the monoid.
|
|
|
|
type SourceValue;
|
|
|
|
|
2023-01-06 16:52:41 -05:00
|
|
|
/// Creates a monoid from a given value.
|
2023-01-08 17:10:05 -05:00
|
|
|
fn new(value: Self::SourceValue) -> Self;
|
|
|
|
|
2023-01-06 16:52:41 -05:00
|
|
|
/// Combines two monoids. This operation must be associative.
|
|
|
|
fn combine(&self, other: &Self) -> Self;
|
|
|
|
}
|