Skip to main content

ValueObject

Trait ValueObject 

Source
pub trait ValueObject:
    Clone
    + PartialEq
    + Debug
    + Send
    + Sync { }
Expand description

A domain object with no identity, whose equality is purely structural: two value objects are the same if their data is the same.

§Examples

use ddd_toolkit_core::domain::ValueObject;

#[derive(Debug, Clone, PartialEq)]
struct Money(u32);

impl ValueObject for Money {}

assert_eq!(Money(500), Money(500));
assert_ne!(Money(500), Money(100));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§