pub trait Semigroup {
// Required method
fn append(self, b: Self) -> Self;
}
Expand description
Semigroup defines some associative operation that can be done to 2 instances of a type.
Examples
String
’s semigroup implementation concatenates the two strings.Vec
’s semigroup implementation concatenates the two Vecs.
Laws
Implementations of Semigroup
must be associative, e.g.
use naan::prelude::*;
let a = || vec![1u8, 2];
let b = || vec![3u8, 4];
let c = || vec![5u8, 6];
assert_eq!(a().append(b().append(c())), a().append(b()).append(c()));