Improve readability of some fmt code examples · model-checking/verify-rust-std@2fcdebb (original) (raw)
`@@ -517,7 +517,10 @@ impl Display for Arguments<'_> {
`
517
517
`///
`
518
518
`/// let origin = Point { x: 0, y: 0 };
`
519
519
`///
`
520
``
`-
/// assert_eq!(format!("The origin is: {origin:?}"), "The origin is: Point { x: 0, y: 0 }");
`
``
520
`+
/// assert_eq!(
`
``
521
`+
/// format!("The origin is: {origin:?}"),
`
``
522
`+
/// "The origin is: Point { x: 0, y: 0 }",
`
``
523
`+
/// );
`
521
524
```` /// ```
`522`
`525`
`///
`
`523`
`526`
`/// Manually implementing:
`
`@@ -541,7 +544,10 @@ impl Display for Arguments<'_> {
`
`541`
`544`
`///
`
`542`
`545`
`/// let origin = Point { x: 0, y: 0 };
`
`543`
`546`
`///
`
`544`
``
`-
/// assert_eq!(format!("The origin is: {origin:?}"), "The origin is: Point { x: 0, y: 0 }");
`
``
`547`
`+
/// assert_eq!(
`
``
`548`
`+
/// format!("The origin is: {origin:?}"),
`
``
`549`
`+
/// "The origin is: Point { x: 0, y: 0 }",
`
``
`550`
`+
/// );
`
`545`
`551`
```` /// ```
546
552
`///
`
547
553
`` /// There are a number of helper methods on the [Formatter
] struct to help you with manual
``
`@@ -582,11 +588,11 @@ impl Display for Arguments<'_> {
`
582
588
`///
`
583
589
`/// let origin = Point { x: 0, y: 0 };
`
584
590
`///
`
585
``
`-
/// assert_eq!(format!("The origin is: {origin:#?}"),
`
586
``
`-
/// "The origin is: Point {
`
``
591
`+
/// let expected = "The origin is: Point {
`
587
592
`/// x: 0,
`
588
593
`/// y: 0,
`
589
``
`-
/// }");
`
``
594
`+
/// }";
`
``
595
`+
/// assert_eq!(format!("The origin is: {origin:#?}"), expected);
`
590
596
```` /// ```
`591`
`597`
``
`592`
`598`
`#[stable(feature = "rust1", since = "1.0.0")]
`
`@@ -738,8 +744,10 @@ pub trait Display {
`
`738`
`744`
`/// }
`
`739`
`745`
`/// }
`
`740`
`746`
`///
`
`741`
``
`-
/// assert_eq!("(1.987, 2.983)",
`
`742`
``
`-
/// format!("{}", Position { longitude: 1.987, latitude: 2.983, }));
`
``
`747`
`+
/// assert_eq!(
`
``
`748`
`+
/// "(1.987, 2.983)",
`
``
`749`
`+
/// format!("{}", Position { longitude: 1.987, latitude: 2.983, }),
`
``
`750`
`+
/// );
`
`743`
`751`
```` /// ```
744
752
`#[stable(feature = "rust1", since = "1.0.0")]
`
745
753
`fn fmt(&self, f: &mut Formatter<'_>) -> Result;
`