diff --git a/crates/core/src/document/html/css.rs b/crates/core/src/document/html/css.rs index 142d5bfd..d257e618 100644 --- a/crates/core/src/document/html/css.rs +++ b/crates/core/src/document/html/css.rs @@ -1,13 +1,13 @@ use fxhash::FxHashSet; use super::style::StyleSheet; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Selector { pub simple_selectors: Vec, pub combinators: Vec, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct SimpleSelector { pub tag_name: Option, pub classes: FxHashSet, @@ -53,27 +53,6 @@ pub enum Combinator { SubsequentSibling, } -impl Default for Selector { - fn default() -> Self { - Selector { - simple_selectors: Vec::new(), - combinators: Vec::new(), - } - } -} - -impl Default for SimpleSelector { - fn default() -> Self { - SimpleSelector { - tag_name: None, - classes: FxHashSet::default(), - pseudo_classes: Vec::new(), - attributes: Vec::new(), - id: None, - } - } -} - pub type Specificity = [usize; 3]; impl Selector { @@ -90,23 +69,13 @@ impl Selector { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Declaration { pub name: String, pub value: String, pub important: bool, } -impl Default for Declaration { - fn default() -> Declaration { - Declaration { - name: String::default(), - value: String::default(), - important: false, - } - } -} - #[derive(Debug, Clone)] pub struct Rule { pub selector: Selector, diff --git a/crates/core/src/document/html/layout.rs b/crates/core/src/document/html/layout.rs index 59c9aee1..c1a67e45 100644 --- a/crates/core/src/document/html/layout.rs +++ b/crates/core/src/document/html/layout.rs @@ -19,7 +19,7 @@ pub struct RootData { pub rect: Rectangle, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct DrawState { pub position: Point, pub floats: FxHashMap>, @@ -30,19 +30,6 @@ pub struct DrawState { pub center_table: bool, } -impl Default for DrawState { - fn default() -> Self { - DrawState { - position: Point::default(), - floats: FxHashMap::default(), - prefix: None, - min_column_widths: Vec::new(), - max_column_widths: Vec::new(), - column_widths: Vec::new(), - center_table: false, - } - } -} #[derive(Debug, Clone)] pub struct StyleData { @@ -114,13 +101,13 @@ pub struct ChildArtifact { pub rects: Vec>, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct SiblingStyle { pub padding: Edge, pub margin: Edge, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct LineStats { pub width: i32, pub merged_width: i32, @@ -128,27 +115,7 @@ pub struct LineStats { pub started: bool, } -impl Default for LineStats { - fn default() -> Self { - LineStats { - width: 0, - merged_width: 0, - glues_count: 0, - started: false, - } - } -} - -impl Default for SiblingStyle { - fn default() -> Self { - SiblingStyle { - padding: Edge::default(), - margin: Edge::default(), - } - } -} - -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct LoopContext { pub index: usize, pub sibling_style: SiblingStyle, @@ -156,17 +123,6 @@ pub struct LoopContext { pub is_last: bool, } -impl Default for LoopContext { - fn default() -> Self { - LoopContext { - index: 0, - sibling_style: SiblingStyle::default(), - is_first: false, - is_last: false, - } - } -} - impl Default for StyleData { fn default() -> Self { StyleData { diff --git a/crates/core/src/font/mod.rs b/crates/core/src/font/mod.rs index 211795f0..82ff88da 100644 --- a/crates/core/src/font/mod.rs +++ b/crates/core/src/font/mod.rs @@ -1645,23 +1645,13 @@ struct GlyphPlan { advance: Point, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct RenderPlan { pub width: i32, scripts: FxHashMap, glyphs: Vec, } -impl Default for RenderPlan { - fn default() -> RenderPlan { - RenderPlan { - width: 0, - scripts: FxHashMap::default(), - glyphs: Vec::new(), - } - } -} - impl RenderPlan { pub fn scale(&self, scale: f32) -> RenderPlan { let width = (scale * self.width as f32) as i32; diff --git a/crates/core/src/framebuffer/mxcfb_sys.rs b/crates/core/src/framebuffer/mxcfb_sys.rs index 83064d5d..722c54a2 100644 --- a/crates/core/src/framebuffer/mxcfb_sys.rs +++ b/crates/core/src/framebuffer/mxcfb_sys.rs @@ -69,7 +69,7 @@ pub struct MxcfbUpdateMarkerData { } #[repr(C)] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct MxcfbAltBufferDataV2 { pub phys_addr: u32, pub width: u32, @@ -77,17 +77,6 @@ pub struct MxcfbAltBufferDataV2 { pub alt_update_region: MxcfbRect, } -impl Default for MxcfbAltBufferDataV2 { - fn default() -> Self { - MxcfbAltBufferDataV2 { - phys_addr: 0, - width: 0, - height: 0, - alt_update_region: MxcfbRect::default(), - } - } -} - #[repr(C)] #[derive(Clone, Debug)] pub struct MxcfbUpdateDataV2 { diff --git a/crates/core/src/geom.rs b/crates/core/src/geom.rs index 3b490703..d827e0f9 100644 --- a/crates/core/src/geom.rs +++ b/crates/core/src/geom.rs @@ -128,7 +128,7 @@ impl fmt::Display for Point { } } -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Default)] pub struct Edge { pub top: i32, pub right: i32, @@ -147,17 +147,6 @@ impl Edge { } } -impl Default for Edge { - fn default() -> Self { - Edge { - top: 0, - right: 0, - bottom: 0, - left: 0, - } - } -} - impl Add for Edge { type Output = Edge; fn add(self, rhs: Edge) -> Edge { diff --git a/crates/core/src/input.rs b/crates/core/src/input.rs index 34bc3437..13fcc388 100644 --- a/crates/core/src/input.rs +++ b/crates/core/src/input.rs @@ -333,20 +333,12 @@ pub fn device_events(rx: Receiver, display: Display, button_scheme: ry } +#[derive(Default)] struct TouchState { position: Point, pressure: i32, } -impl Default for TouchState { - fn default() -> Self { - TouchState { - position: Point::default(), - pressure: 0, - } - } -} - pub fn parse_device_events(rx: &Receiver, ty: &Sender, display: Display, button_scheme: ButtonScheme) { let mut id = 0; let mut last_activity = -60; diff --git a/crates/core/src/metadata.rs b/crates/core/src/metadata.rs index fd4be29b..9b294baa 100644 --- a/crates/core/src/metadata.rs +++ b/crates/core/src/metadata.rs @@ -62,7 +62,7 @@ pub struct Info { pub added: NaiveDateTime, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] #[serde(default, rename_all = "camelCase")] pub struct FileInfo { pub path: PathBuf, @@ -70,16 +70,6 @@ pub struct FileInfo { pub size: u64, } -impl Default for FileInfo { - fn default() -> Self { - FileInfo { - path: PathBuf::default(), - kind: String::default(), - size: u64::default(), - } - } -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(default, rename_all = "camelCase")] pub struct Annotation { diff --git a/crates/core/src/settings/mod.rs b/crates/core/src/settings/mod.rs index 2cffab5e..d8e133b3 100644 --- a/crates/core/src/settings/mod.rs +++ b/crates/core/src/settings/mod.rs @@ -274,7 +274,7 @@ pub enum SecondColumn { Year, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] #[serde(default, rename_all = "kebab-case")] pub struct Hook { pub path: PathBuf, @@ -284,18 +284,6 @@ pub struct Hook { pub second_column: Option, } -impl Default for Hook { - fn default() -> Self { - Hook { - path: PathBuf::default(), - program: PathBuf::default(), - sort_method: None, - first_column: None, - second_column: None, - } - } -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(default, rename_all = "kebab-case")] pub struct HomeSettings { diff --git a/crates/core/src/view/home/directories_bar.rs b/crates/core/src/view/home/directories_bar.rs index 62efd38f..404f7589 100644 --- a/crates/core/src/view/home/directories_bar.rs +++ b/crates/core/src/view/home/directories_bar.rs @@ -24,23 +24,13 @@ pub struct DirectoriesBar { current_page: usize, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] struct Page<'a> { start_index: usize, end_index: usize, lines: Vec>, } -impl<'a> Default for Page<'a> { - fn default() -> Page<'a> { - Page { - start_index: 0, - end_index: 0, - lines: Vec::new(), - } - } -} - #[derive(Debug, Clone)] struct Layout { x_height: i32, @@ -49,23 +39,13 @@ struct Layout { max_lines: usize, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] struct Line<'a> { width: i32, labels_count: usize, items: Vec>, } -impl<'a> Default for Line<'a> { - fn default() -> Line<'a> { - Line { - width: 0, - labels_count: 0, - items: Vec::new(), - } - } -} - #[derive(Debug, Clone)] enum Item<'a> { Label { path: &'a Path, width: i32, max_width: Option },