Skip to content

Commit 2874811

Browse files
committed
fix(lance-graph-contract): clippy::derivable_impls — derive Default with #[default] variant
CI `clippy` job (PR #404) flagged two `clippy::derivable_impls` warnings in the 0.2.0 additive submodules. Both manual `impl Default` blocks replaced with `#[derive(Default)]` on the enum + `#[default]` attribute on the chosen variant: * SupervisionPolicy: derive Default; mark OneForOne with #[default]. Kept a const fn one_for_one() constructor for call-site readability. * EngineHint: derive Default; mark Auto with #[default]. 441/441 lance-graph-contract lib tests still pass. clippy clean. CI signal: PR #404 clippy.
1 parent 738efbc commit 2874811

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

crates/lance-graph-contract/src/actor.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,22 @@ use core::time::Duration;
3030
/// Mirrors Erlang/OTP's classic three supervisor strategies. The
3131
/// `cognitive-shader-actor` crate maps these onto ractor's supervisor
3232
/// hierarchy; this enum is the contract vocabulary.
33-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
33+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
3434
#[non_exhaustive]
3535
pub enum SupervisionPolicy {
3636
/// Restart only the failed child.
37+
#[default]
3738
OneForOne,
3839
/// Restart all children on any failure (use when children share state).
3940
OneForAll,
4041
/// Restart the failed child and every child started after it.
4142
RestForOne,
4243
}
4344

44-
impl Default for SupervisionPolicy {
45-
fn default() -> Self {
45+
impl SupervisionPolicy {
46+
/// Convenience constructor for the default policy. Equivalent to
47+
/// `SupervisionPolicy::default()`, kept for call-site readability.
48+
pub const fn one_for_one() -> Self {
4649
Self::OneForOne
4750
}
4851
}

crates/lance-graph-contract/src/ir.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl fmt::Display for Cardinality {
7676
/// Adding a new engine is an additive enum variant — existing consumers
7777
/// continue to compile (they will get a `non_exhaustive`-style warning
7878
/// if they `match` exhaustively; mitigation: use `_ =>`).
79-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
79+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
8080
#[non_exhaustive]
8181
pub enum EngineHint {
8282
/// Embedded LSM KV (RocksDB / SurrealKV).
@@ -92,15 +92,10 @@ pub enum EngineHint {
9292
/// Cognitive shader (lance-graph-cognitive crates).
9393
Cognitive,
9494
/// Engine selection is deferred to the planner's cost model.
95+
#[default]
9596
Auto,
9697
}
9798

98-
impl Default for EngineHint {
99-
fn default() -> Self {
100-
Self::Auto
101-
}
102-
}
103-
10499
/// Operator kind. The IR is intentionally coarse — it carries enough
105100
/// signal for routing decisions, not enough to be a full physical plan.
106101
///

0 commit comments

Comments
 (0)