diff --git a/idioms/default.html b/idioms/default.html index 981092e..c4246bd 100644 --- a/idioms/default.html +++ b/idioms/default.html @@ -182,13 +182,15 @@ types implement Default, the more useful it becomes.

default() method does not. There can even be multiple constructors with different names, but there can only be one Default implementation per type.

Example

-
// note that we can simply auto-derive Default here.
-#[derive(Default)]
+
use std::{path::PathBuf, time::Duration};
+
+// note that we can simply auto-derive Default here.
+#[derive(Default, Debug)]
 struct MyConfiguration {
     // Option defaults to None
-    output: Option<Path>,
+    output: Option<PathBuf>,
     // Vecs default to empty vector
-    search_path: Vec<Path>,
+    search_path: Vec<PathBuf>,
     // Duration defaults to zero time
     timeout: Duration,
     // bool defaults to false
@@ -202,9 +204,11 @@ impl MyConfiguration {
 fn main() {
     // construct a new instance with default values
     let mut conf = MyConfiguration::default();
-    // do somthing with conf here
+    // do something with conf here
+    conf.check = true;
+    println!("conf = {:#?}", conf);
 }
-
+

See also