mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-07-07 21:35:17 +00:00

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
37 lines
811 B
Rust
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);
|
|
})
|
|
}
|