refactor!: K comes first in History, HistoryBuilder and Joint
`K` is the one type parameter people change, and it was last. Naming a
history in a struct field meant writing all four to say one thing:
struct Ladder { history: History<i64, ConstantDrift, NullObserver, String> }
struct Analysis<'h> { joint: Joint<'h, i64, ConstantDrift, NullObserver, &'static str> }
Now:
struct Ladder { history: History<String> }
struct Analysis<'h> { joint: Joint<'h> }
`History<K, T, D, O>`, all four defaulted. Bounds may reference later
parameters, so `D: Drift<T> = ConstantDrift` is legal in third position.
`Joint` gains the same defaults, so `Joint<'h, String>` spells it.
72 call sites swapped, and the reorder makes most of them shorter: 18
now read `History<String>` and the `&'static str` ones read `History`.
The two turbofished builders shrink from
`HistoryBuilder::<Untimed, _, _, String>::new()` to
`HistoryBuilder::<String, Untimed>::new()`.
`Joint` keeps `O` structurally, defaulted rather than removed. #72 notes
it never touches the observer, which is true — but it borrows the whole
`&'h History<K, T, D, O>` and calls `History::resolve_terms`, so dropping
the parameter means either a view type or moving that method off
`History`. The default already buys the entire user-visible benefit,
which was the spelling.
Refs #72.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011hcFjNDmHXZF8URGLku5zZ
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
//! Both key types are exercised in every test, because the point is that the
|
||||
//! spelling is the same.
|
||||
|
||||
use trueskill_tt::{ConstantDrift, History, NullObserver};
|
||||
use trueskill_tt::{ConstantDrift, History};
|
||||
|
||||
type Owned = History<i64, ConstantDrift, NullObserver, String>;
|
||||
type Borrowed = History<i64, ConstantDrift, NullObserver, &'static str>;
|
||||
type Owned = History<String>;
|
||||
type Borrowed = History;
|
||||
|
||||
fn owned() -> Owned {
|
||||
let mut h: Owned = History::builder().key_type::<String>().build();
|
||||
|
||||
Reference in New Issue
Block a user