Skip to main content

AddSemigroup

Trait AddSemigroup 

Source
pub trait AddSemigroup:
    Add<Output = Self>
    + Associative
    + Clone { }
Expand description

Represents an Additive Semigroup.

A semigroup is an algebraic structure with a single associative binary operation. Unlike a monoid, a semigroup does NOT require an identity element.

§Mathematical Definition

A set S with a binary operation + is an additive semigroup if:

  1. Closure: a + b is in S for all a, b in S. (Implicit in Rust).
  2. Associativity: (a + b) + c = a + (b + c) for all a, b, c in S.

§Examples

  • Positive integers under addition (no zero identity).
  • Non-empty strings under concatenation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> AddSemigroup for T
where T: Add<Output = Self> + Associative + Clone,