Skip to content

Commit

Permalink
fix: clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gluax committed Apr 8, 2024
1 parent aae49b3 commit a34154e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions crates/snops-common/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum AgentState {
// A node in the inventory can function as a transaction cannon
Inventory,
/// Test id mapping to node state
Node(EnvId, NodeState),
Node(EnvId, Box<NodeState>),
}

impl AgentState {
Expand All @@ -36,15 +36,18 @@ impl AgentState {
{
match self {
Self::Inventory => Self::Inventory,
Self::Node(id, state) => Self::Node(id, f(state)),
Self::Node(id, state) => Self::Node(id, Box::new(f(*state))),
}
}

pub fn is_persist(&self) -> bool {
// bc box NodeState is unstable https://github.com/rust-lang/rust/issues/29641
matches!(
self,
AgentState::Node(
_,
node_state_box // Use a placeholder for the Box<NodeState>
) if matches!(&**node_state_box, // Dereference the Box to match its content
NodeState {
height: (_, HeightRequest::Persist),
..
Expand Down
2 changes: 1 addition & 1 deletion crates/snops/src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ pub async fn initial_reconcile(env_id: usize, state: &GlobalState) -> Result<(),
.filter(not_me)
.collect();

let agent_state = AgentState::Node(env_id, node_state);
let agent_state = AgentState::Node(env_id, Box::new(node_state));
pending_reconciliations.push((id, client, agent_state));
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/snops/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl Agent {
self.id(),
self.client_owned()?,
match &self.state {
AgentState::Node(id, state) => AgentState::Node(*id, f(state.clone())),
AgentState::Node(id, state) => AgentState::Node(*id, Box::new(f(*state.clone()))),
_ => return None,
},
))
Expand Down

0 comments on commit a34154e

Please sign in to comment.