sim: Implement Default for a few types
Clippy suggests implementing Default when the `new` function for that
type just initializes the type to default values.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/mcuboot-sys/src/api.rs b/sim/mcuboot-sys/src/api.rs
index 8f8b7be..7bd4fc4 100644
--- a/sim/mcuboot-sys/src/api.rs
+++ b/sim/mcuboot-sys/src/api.rs
@@ -46,6 +46,16 @@
}
}
+impl Default for FlashContext {
+ fn default() -> FlashContext {
+ FlashContext {
+ flash_map: HashMap::new(),
+ flash_params: HashMap::new(),
+ flash_areas: CAreaDescPtr{ptr: ptr::null()},
+ }
+ }
+}
+
#[repr(C)]
#[derive(Debug, Default)]
pub struct CSimContext {
@@ -71,6 +81,14 @@
}
}
+impl Default for CSimContextPtr {
+ fn default() -> CSimContextPtr {
+ CSimContextPtr {
+ ptr: ptr::null(),
+ }
+ }
+}
+
thread_local! {
pub static THREAD_CTX: RefCell<FlashContext> = RefCell::new(FlashContext::new());
pub static SIM_CTX: RefCell<CSimContextPtr> = RefCell::new(CSimContextPtr::new());