@@ -744,13 +744,15 @@ msgstr ""
744
744
745
745
#: src\idioms/ctor.md:8
746
746
msgid ""
747
- "```rust\r\n"
747
+ "```` rust\r\n"
748
748
"/// Time in seconds.\r\n"
749
749
"///\r\n"
750
750
"/// # Example\r\n"
751
+ "///\r\n"
752
+ "/// ```\r\n"
751
753
"/// let s = Second::new(42);\r\n"
752
754
"/// assert_eq!(42, s.value());\r\n"
753
- "\r\n"
755
+ "/// ``` \r\n"
754
756
"pub struct Second {\r\n"
755
757
" value: u64\r\n"
756
758
"}\r\n"
@@ -767,27 +769,29 @@ msgid ""
767
769
" self.value\r\n"
768
770
" }\r\n"
769
771
"}\r\n"
770
- "```"
772
+ "```` "
771
773
msgstr ""
772
774
773
- #: src\idioms/ctor.md:33
775
+ #: src\idioms/ctor.md:35
774
776
msgid "## Default Constructors\r"
775
777
msgstr ""
776
778
777
- #: src\idioms/ctor.md:35
779
+ #: src\idioms/ctor.md:37
778
780
msgid ""
779
781
"Rust supports default constructors with the [`Default`][std-default] trait:"
780
782
msgstr ""
781
783
782
- #: src\idioms/ctor.md:37
784
+ #: src\idioms/ctor.md:39
783
785
msgid ""
784
- "```rust\r\n"
786
+ "```` rust\r\n"
785
787
"/// Time in seconds.\r\n"
786
788
"///\r\n"
787
789
"/// # Example\r\n"
788
790
"///\r\n"
791
+ "/// ```\r\n"
789
792
"/// let s = Second::default();\r\n"
790
793
"/// assert_eq!(0, s.value());\r\n"
794
+ "/// ```\r\n"
791
795
"pub struct Second {\r\n"
792
796
" value: u64\r\n"
793
797
"}\r\n"
@@ -804,19 +808,27 @@ msgid ""
804
808
" Self { value: 0 }\r\n"
805
809
" }\r\n"
806
810
"}\r\n"
807
- "```"
811
+ "```` "
808
812
msgstr ""
809
813
810
- #: src\idioms/ctor.md:62
814
+ #: src\idioms/ctor.md:66
811
815
msgid ""
812
816
"`Default` can also be derived if all types of all fields implement "
813
817
"`Default`,\r\n"
814
818
"like they do with `Second`:"
815
819
msgstr ""
816
820
817
- #: src\idioms/ctor.md:65
821
+ #: src\idioms/ctor.md:69
818
822
msgid ""
819
- "```rust\r\n"
823
+ "````rust\r\n"
824
+ "/// Time in seconds.\r\n"
825
+ "///\r\n"
826
+ "/// # Example\r\n"
827
+ "///\r\n"
828
+ "/// ```\r\n"
829
+ "/// let s = Second::default();\r\n"
830
+ "/// assert_eq!(0, s.value());\r\n"
831
+ "/// ```\r\n"
820
832
"#[derive(Default)]\r\n"
821
833
"pub struct Second {\r\n"
822
834
" value: u64\r\n"
@@ -828,10 +840,10 @@ msgid ""
828
840
" self.value\r\n"
829
841
" }\r\n"
830
842
"}\r\n"
831
- "```"
843
+ "```` "
832
844
msgstr ""
833
845
834
- #: src\idioms/ctor.md:79
846
+ #: src\idioms/ctor.md:91
835
847
msgid ""
836
848
"**Note:** It is common and expected for types to implement both\r\n"
837
849
"`Default` and an empty `new` constructor. `new` is the constructor\r\n"
@@ -840,7 +852,7 @@ msgid ""
840
852
"should, even if it is functionally identical to default."
841
853
msgstr ""
842
854
843
- #: src\idioms/ctor.md:85
855
+ #: src\idioms/ctor.md:97
844
856
msgid ""
845
857
"**Hint:** The advantage of implementing or deriving `Default` is that your "
846
858
"type\r\n"
@@ -849,11 +861,11 @@ msgid ""
849
861
"any of the [`*or_default` functions in the standard library][std-or-default]."
850
862
msgstr ""
851
863
852
- #: src\idioms/ctor.md:89
864
+ #: src\idioms/ctor.md:101
853
865
msgid "## See also\r"
854
866
msgstr ""
855
867
856
- #: src\idioms/ctor.md:91
868
+ #: src\idioms/ctor.md:103
857
869
msgid ""
858
870
"- The [default idiom](default.md) for a more in-depth description of the\r\n"
859
871
" `Default` trait.\r\n"
@@ -2454,7 +2466,7 @@ msgstr ""
2454
2466
2455
2467
#: src\idioms/rustdoc-init.md:16
2456
2468
msgid ""
2457
- "```rust,ignore\r\n"
2469
+ "```` rust,ignore\r\n"
2458
2470
"struct Connection {\r\n"
2459
2471
" name: String,\r\n"
2460
2472
" stream: TcpStream,\r\n"
@@ -2464,14 +2476,16 @@ msgid ""
2464
2476
" /// Sends a request over the connection.\r\n"
2465
2477
" ///\r\n"
2466
2478
" /// # Example\r\n"
2467
- " /// # Boilerplate are required to get an example working.\r\n"
2479
+ " /// ```no_run\r\n"
2480
+ " /// # // Boilerplate are required to get an example working.\r\n"
2468
2481
" /// # let stream = TcpStream::connect(\" 127.0.0.1:34254\" );\r\n"
2469
2482
" /// # let connection = Connection { name: \" foo\" .to_owned(), stream "
2470
2483
"};\r\n"
2471
2484
" /// # let request = Request::new(\" RequestId\" , RequestType::Get, "
2472
2485
"\" payload\" );\r\n"
2473
2486
" /// let response = connection.send_request(request);\r\n"
2474
2487
" /// assert!(response.is_ok());\r\n"
2488
+ " /// ```\r\n"
2475
2489
" fn send_request(&self, request: Request) -> Result<Status, SendErr> {\r\n"
2476
2490
" // ...\r\n"
2477
2491
" }\r\n"
@@ -2481,24 +2495,24 @@ msgid ""
2481
2495
" // ...\r\n"
2482
2496
" }\r\n"
2483
2497
"}\r\n"
2484
- "```"
2498
+ "```` "
2485
2499
msgstr ""
2486
2500
2487
- #: src\idioms/rustdoc-init.md:43
2501
+ #: src\idioms/rustdoc-init.md:45
2488
2502
msgid "## Example\r"
2489
2503
msgstr ""
2490
2504
2491
- #: src\idioms/rustdoc-init.md:45
2505
+ #: src\idioms/rustdoc-init.md:47
2492
2506
msgid ""
2493
2507
"Instead of typing all of this boilerplate to create a `Connection` and\r\n"
2494
2508
"`Request`, it is easier to just create a wrapping helper function which "
2495
2509
"takes\r\n"
2496
2510
"them as arguments:"
2497
2511
msgstr ""
2498
2512
2499
- #: src\idioms/rustdoc-init.md:49
2513
+ #: src\idioms/rustdoc-init.md:51
2500
2514
msgid ""
2501
- "```rust,ignore\r\n"
2515
+ "```` rust,ignore\r\n"
2502
2516
"struct Connection {\r\n"
2503
2517
" name: String,\r\n"
2504
2518
" stream: TcpStream,\r\n"
@@ -2508,38 +2522,40 @@ msgid ""
2508
2522
" /// Sends a request over the connection.\r\n"
2509
2523
" ///\r\n"
2510
2524
" /// # Example\r\n"
2525
+ " /// ```\r\n"
2511
2526
" /// # fn call_send(connection: Connection, request: Request) {\r\n"
2512
2527
" /// let response = connection.send_request(request);\r\n"
2513
2528
" /// assert!(response.is_ok());\r\n"
2514
2529
" /// # }\r\n"
2530
+ " /// ```\r\n"
2515
2531
" fn send_request(&self, request: Request) {\r\n"
2516
2532
" // ...\r\n"
2517
2533
" }\r\n"
2518
2534
"}\r\n"
2519
- "```"
2535
+ "```` "
2520
2536
msgstr ""
2521
2537
2522
- #: src\idioms/rustdoc-init.md:69
2538
+ #: src\idioms/rustdoc-init.md:73
2523
2539
msgid ""
2524
2540
"**Note** in the above example the line `assert!(response.is_ok());` will "
2525
2541
"not\r\n"
2526
2542
"actually run while testing because it is inside a function which is never\r\n"
2527
2543
"invoked."
2528
2544
msgstr ""
2529
2545
2530
- #: src\idioms/rustdoc-init.md:73
2546
+ #: src\idioms/rustdoc-init.md:77
2531
2547
msgid "## Advantages\r"
2532
2548
msgstr ""
2533
2549
2534
- #: src\idioms/rustdoc-init.md:75
2550
+ #: src\idioms/rustdoc-init.md:79
2535
2551
msgid "This is much more concise and avoids repetitive code in examples."
2536
2552
msgstr ""
2537
2553
2538
- #: src\idioms/rustdoc-init.md:77
2554
+ #: src\idioms/rustdoc-init.md:81
2539
2555
msgid "## Disadvantages\r"
2540
2556
msgstr ""
2541
2557
2542
- #: src\idioms/rustdoc-init.md:79
2558
+ #: src\idioms/rustdoc-init.md:83
2543
2559
msgid ""
2544
2560
"As example is in a function, the code will not be tested. Though it will "
2545
2561
"still be\r\n"
@@ -2549,15 +2565,15 @@ msgid ""
2549
2565
"`no_run`."
2550
2566
msgstr ""
2551
2567
2552
- #: src\idioms/rustdoc-init.md:83
2568
+ #: src\idioms/rustdoc-init.md:87
2553
2569
msgid "## Discussion\r"
2554
2570
msgstr ""
2555
2571
2556
- #: src\idioms/rustdoc-init.md:85
2572
+ #: src\idioms/rustdoc-init.md:89
2557
2573
msgid "If assertions are not required this pattern works well."
2558
2574
msgstr ""
2559
2575
2560
- #: src\idioms/rustdoc-init.md:87
2576
+ #: src\idioms/rustdoc-init.md:91
2561
2577
msgid ""
2562
2578
"If they are, an alternative can be to create a public method to create a "
2563
2579
"helper\r\n"
0 commit comments