From 92db385801819a7610d2448f4d4a0cf356a52062 Mon Sep 17 00:00:00 2001 From: Francisco Gonzalez Date: Mon, 20 Nov 2023 01:30:20 +0100 Subject: [PATCH] Avoid stack overflow uisng Box --- examples/app.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/app.rs b/examples/app.rs index 1cfcb1c..9f7b18d 100644 --- a/examples/app.rs +++ b/examples/app.rs @@ -58,7 +58,8 @@ fn load(fname: &str, ctx: &mut ModbusContextFull) -> Result<(), Box> let mut file = File::open(fname)?; let mut data: Vec = Vec::new(); file.read_to_end(&mut data)?; - (*ctx, _) = bincode::decode_from_slice(&data, config)?; + let (bctx, _): (Box, usize) = bincode::decode_from_slice(&data, config)?; + *ctx = *bctx; Ok(()) }