Merge api/non-exhaustive-options (#74)

This commit is contained in:
2026-09-09 22:05:11 +02:00
+13
View File
@@ -11,6 +11,14 @@ use smallvec::SmallVec;
/// carried by `GameOptions` for a single match scored without a history. The /// carried by `GameOptions` for a single match scored without a history. The
/// defaults are the crate's globals: [`ITERATIONS`](crate::ITERATIONS), /// defaults are the crate's globals: [`ITERATIONS`](crate::ITERATIONS),
/// [`EPSILON`](crate::EPSILON), and undamped EP. /// [`EPSILON`](crate::EPSILON), and undamped EP.
///
/// Deliberately **not** `#[non_exhaustive]`, unlike [`ConvergenceReport`]. The
/// usual argument for marking an options struct is that `..Default::default()`
/// makes a future field additive — but `Default::default` is not a `const fn`,
/// so marking it would make
/// `const OPTS: ConvergenceOptions = ConvergenceOptions { .. }` impossible from
/// outside the crate, with no workaround. This type is `Copy` and a natural
/// const; that cost is permanent, and adding a field is a one-time major bump.
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub struct ConvergenceOptions { pub struct ConvergenceOptions {
/// Hard cap on full forward+backward sweeps. /// Hard cap on full forward+backward sweeps.
@@ -89,7 +97,12 @@ impl Default for ConvergenceOptions {
/// [`InferenceError::NotConverged`](crate::InferenceError::NotConverged) there. /// [`InferenceError::NotConverged`](crate::InferenceError::NotConverged) there.
/// From [`History::converge_partial`](crate::History::converge_partial) it may /// From [`History::converge_partial`](crate::History::converge_partial) it may
/// not be, and `converged` is what says so. /// not be, and `converged` is what says so.
/// Constructed only by `converge` / `converge_partial`, never by a caller, so
/// `#[non_exhaustive]` costs nothing here and lets a future field be additive.
/// The two *options* structs deliberately do not carry it — see the note on
/// [`ConvergenceOptions`].
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct ConvergenceReport { pub struct ConvergenceReport {
/// Full forward+backward sweeps actually run. `0` for a history with no /// Full forward+backward sweeps actually run. `0` for a history with no
/// time slices, which is converged trivially. /// time slices, which is converged trivially.