salsa/tests/tracked_with_struct_ord.rs
Micha Reiser 96eeecb5af
Some checks are pending
Book / Book (push) Waiting to run
Book / Deploy (push) Blocked by required conditions
Release-plz / Release-plz PR (push) Waiting to run
Release-plz / Release-plz release (push) Waiting to run
Test / Test (push) Waiting to run
Test / Miri (push) Waiting to run
Test / Benchmarks (push) Waiting to run
Remove default PartialOrd and Ord derives for salsa-structs (#868)
2025-05-19 11:57:23 +00:00

37 lines
811 B
Rust

//! Test that `PartialOrd` and `Ord` can be derived for tracked structs
use salsa::{Database, DatabaseImpl};
use test_log::test;
#[salsa::input]
#[derive(PartialOrd, Ord)]
struct Input {
value: usize,
}
#[salsa::tracked(debug)]
#[derive(Ord, PartialOrd)]
struct MyTracked<'db> {
value: usize,
}
#[salsa::tracked]
fn create_tracked(db: &dyn Database, input: Input) -> MyTracked<'_> {
MyTracked::new(db, input.value(db))
}
#[test]
fn execute() {
DatabaseImpl::new().attach(|db| {
let input1 = Input::new(db, 20);
let input2 = Input::new(db, 10);
// Compares by ID and not by value.
assert!(input1 <= input2);
let t0: MyTracked = create_tracked(db, input1);
let t1: MyTracked = create_tracked(db, input2);
assert!(t0 <= t1);
})
}