GCC Code Coverage Report


src/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
9 / 9
100.0%
Branches:
-
-%
Functions:
2 / 2
100.0%

util/save-and-restore.spice
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 // Generic type defs
4 type T dyn;
5
6 /**
7 * RAII helper to save a value and restore it when the object of this class goes out of scope
8 *
9 * @tparam T Value type
10 */
11 public type SaveAndRestore<T> struct {
12 T& value
13 T oldValue
14 }
15
16 2219346 public p SaveAndRestore.ctor(T& value, const T& newValue) {
17 2219346 this.value = value;
18 2219346 this.oldValue = value;
19 2219346 T newValueCopy = newValue;
20 2219346 value = newValueCopy;
21 2219346 }
22
23 2219346 public p SaveAndRestore.dtor() {
24 2219346 this.value = this.oldValue;
25 2219346 }
26