equal

Function equal 

Source
pub fn equal<A, T, F>(key: F) -> EqualJoiner<F, F, T>
where T: PartialEq, F: Fn(&A) -> T + Clone + Send + Sync,
Expand description

Creates a joiner that matches when a property is equal on both sides.

This is the primary joiner for self-joins where you’re matching entities from the same collection on a shared property.

§Example

use solverforge_scoring::stream::joiner::{Joiner, equal};

#[derive(Clone)]
struct Shift { employee_id: Option<usize>, start: i64 }

// Match shifts with the same employee (self-join)
let same_employee = equal(|s: &Shift| s.employee_id);

let a = Shift { employee_id: Some(5), start: 0 };
let b = Shift { employee_id: Some(5), start: 8 };
let c = Shift { employee_id: Some(3), start: 16 };

assert!(same_employee.matches(&a, &b));
assert!(!same_employee.matches(&a, &c));