refactor!: retire Index, intern and lookup
`Index` was public, `History::intern` and `History::lookup` returned
one, and no public method anywhere accepted one. It was a handle with
nowhere to go — and `key_table.rs` advertised the hot-path story it was
meant to enable ("power users can promote `&K` to `Index` and skip the
lookup"), which was never reachable through the public API.
It also shadowed `std::ops::Index`, which `CompetitorStore` implements,
so `use trueskill_tt::*` alongside `use std::ops::*` collided.
All three are `pub(crate)` now. `intern` stays internal because
ingestion needs it; `lookup` is gone entirely, since `current_skill`,
`rating` and `learning_curve` already answer "does this history know
this key" and all three take a borrowed key.
The three tests that used them asserted things a caller cannot observe.
They now assert what the interning bought:
- `record_winner_creates_two_competitors` compares posteriors instead of
comparing two opaque indices for inequality.
- `intern_is_idempotent` becomes `a_repeated_key_is_one_competitor` — a
key appearing in two events gives one competitor with a two-point
learning curve, which is the observable form of the same claim.
- `lookup_returns_none_for_missing` becomes `an_unknown_key_is_unknown`.
Closes #73.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011hcFjNDmHXZF8URGLku5zZ
This commit is contained in:
@@ -77,17 +77,18 @@ fn linear_combinations_take_bare_keys() {
|
||||
);
|
||||
}
|
||||
|
||||
/// `lookup` is gone with `Index` (#73); the accessors that answer the same
|
||||
/// question all take a borrowed key.
|
||||
#[test]
|
||||
fn lookup_accepts_a_borrowed_key_like_its_neighbours() {
|
||||
// `lookup` carried `ToOwned<Owned = K>`, copy-pasted from `intern`, which
|
||||
// genuinely needs it to create the entry. `lookup` never creates.
|
||||
fn membership_queries_accept_a_borrowed_key() {
|
||||
let h = owned();
|
||||
assert!(h.lookup("alice").is_some());
|
||||
assert!(h.lookup("nobody").is_none());
|
||||
|
||||
// Control: its neighbours already accepted this and must still.
|
||||
assert!(h.current_skill("alice").is_some());
|
||||
assert!(h.rating("alice").is_some());
|
||||
assert!(h.learning_curve("alice").is_some());
|
||||
|
||||
assert!(h.current_skill("nobody").is_none());
|
||||
assert!(h.rating("nobody").is_none());
|
||||
assert!(h.learning_curve("nobody").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user