Skip to content

Commit

Permalink
fixup: define roundtrip_to_extract_type outside of other function
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h committed Nov 8, 2024
1 parent ae85929 commit 531ddd4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/cli/subcommand/split_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,6 @@ async fn two_phased_can_parse_receipt_perfectly(
diagnostic_data: phase1_plan.diagnostic_data.clone(),
};

fn roundtrip_to_extract_type<T: serde::de::DeserializeOwned>(
action: &StatefulAction<Box<dyn Action>>,
action_tag: &str,
) -> eyre::Result<StatefulAction<T>> {
let action_json = serde_json::to_string(action).with_context(|| {
format!("serde_json::to_string'ing {action_tag} json to extract real type")
})?;
let action_unjson: StatefulAction<T> =
serde_json::from_str(&action_json).with_context(|| {
format!("serde_json::from_str'ing {action_tag} json to extract real type")
})?;

Ok(action_unjson)
}

for action in phase1_plan.actions.iter_mut() {
let inner_typetag_name = action.inner_typetag_name();
match inner_typetag_name {
Expand Down Expand Up @@ -475,3 +460,18 @@ async fn two_phased_cannot_parse_receipt_perfectly(

Ok(())
}

fn roundtrip_to_extract_type<T: serde::de::DeserializeOwned>(
action: &StatefulAction<Box<dyn Action>>,
action_tag: &str,
) -> eyre::Result<StatefulAction<T>> {
let action_json = serde_json::to_string(action).with_context(|| {
format!("serde_json::to_string'ing {action_tag} json to extract real type")
})?;
let action_unjson: StatefulAction<T> =
serde_json::from_str(&action_json).with_context(|| {
format!("serde_json::from_str'ing {action_tag} json to extract real type")
})?;

Ok(action_unjson)
}

0 comments on commit 531ddd4

Please sign in to comment.