Commit fc8e3c5b authored by David Brown's avatar David Brown Committed by David Brown
Browse files

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: default avatarDavid Brown <david.brown@linaro.org>
parent 50b5a12c
Loading
Loading
Loading
Loading
+18 −0
Changes for sim/mcuboot-sys/src/api.rs: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -46,6 +46,16 @@ impl FlashContext {
    }
}

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 CSimContextPtr {
    }
}

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());
+1 −1
Changes for sim/mcuboot-sys/src/area.rs: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ use std::ptr;
use std::collections::HashMap;

/// Structure to build up the boot area table.
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
pub struct AreaDesc {
    areas: Vec<Vec<FlashArea>>,
    whole: Vec<FlashArea>,
+1 −0
Changes for sim/src/lib.rs: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ pub fn main() {
    }
}

#[derive(Default)]
pub struct RunStatus {
    failures: usize,
    passes: usize,