Skip to content

Commit 6a71eba

Browse files
committed
Make preview take a non mut context
1 parent d0cc1ab commit 6a71eba

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

core/src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,17 @@ pub fn evaluate_with_interrupt(
485485
/// also disabled. Currency conversions (exchange rates) are disabled.
486486
pub fn evaluate_preview_with_interrupt(
487487
input: &str,
488-
context: &mut Context,
488+
context: &Context,
489489
int: &impl Interrupt,
490490
) -> FendResult {
491491
let empty = FendResult::empty();
492492
// unfortunately making a complete copy of the context is necessary
493493
// because we want variables to still work in multi-statement inputs
494494
// like `a = 2; 5a`.
495-
let context_clone = context.clone();
496-
context.random_u32 = None;
497-
context.get_exchange_rate = None;
498-
let result = evaluate_with_interrupt_internal(input, context, int);
499-
*context = context_clone;
495+
let mut context_clone = context.clone();
496+
context_clone.random_u32 = None;
497+
context_clone.get_exchange_rate = None;
498+
let result = evaluate_with_interrupt_internal(input, &mut context_clone, int);
500499
let Ok(result) = result else {
501500
return empty;
502501
};

0 commit comments

Comments
 (0)