chiark / gitweb /
Derive Default and use it instead of open-coding in new
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Feb 2024 12:58:15 +0000 (12:58 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Feb 2024 14:26:16 +0000 (14:26 +0000)
src/text.rs

index af33780fd9583bcc3d1c34ef28ffc6f789c9d93d..e20223a836c327bdc96fe976020b5881039ffa97 100644 (file)
@@ -1044,13 +1044,14 @@ fn test_html() {
         });
 }
 
+#[derive(Default)]
 pub struct ExtendableIndicator {
     primed: bool,
 }
 
 impl ExtendableIndicator {
     pub fn new() -> Self {
-        ExtendableIndicator { primed: false }
+        Default::default()
     }
 
     pub fn set_primed(&mut self, primed: bool) {
@@ -1682,6 +1683,7 @@ struct Keypress {
     description: ColouredString,
 }
 
+#[derive(Default)]
 pub struct FileStatusLine {
     keypresses: Vec<(Keypress, usize)>, // each with display priority
     proportion: Option<u32>,
@@ -1697,11 +1699,7 @@ impl FileStatusLine {
     const SPACING: usize = 2;
 
     pub fn new() -> FileStatusLine {
-        FileStatusLine {
-            keypresses: Vec::new(),
-            proportion: None,
-            message: None,
-        }
+        Default::default()
     }
 
     pub fn set_proportion(mut self, numer: usize, denom: usize) -> Self {