Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2fcdebb

Browse files
committedJul 5, 2024
Improve readability of some fmt code examples
1 parent a8b6d0a commit 2fcdebb

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed
 

‎core/src/fmt/mod.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,10 @@ impl Display for Arguments<'_> {
517517
///
518518
/// let origin = Point { x: 0, y: 0 };
519519
///
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+
/// );
521524
/// ```
522525
///
523526
/// Manually implementing:
@@ -541,7 +544,10 @@ impl Display for Arguments<'_> {
541544
///
542545
/// let origin = Point { x: 0, y: 0 };
543546
///
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+
/// );
545551
/// ```
546552
///
547553
/// There are a number of helper methods on the [`Formatter`] struct to help you with manual
@@ -582,11 +588,11 @@ impl Display for Arguments<'_> {
582588
///
583589
/// let origin = Point { x: 0, y: 0 };
584590
///
585-
/// assert_eq!(format!("The origin is: {origin:#?}"),
586-
/// "The origin is: Point {
591+
/// let expected = "The origin is: Point {
587592
/// x: 0,
588593
/// y: 0,
589-
/// }");
594+
/// }";
595+
/// assert_eq!(format!("The origin is: {origin:#?}"), expected);
590596
/// ```
591597
592598
#[stable(feature = "rust1", since = "1.0.0")]
@@ -738,8 +744,10 @@ pub trait Display {
738744
/// }
739745
/// }
740746
///
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+
/// );
743751
/// ```
744752
#[stable(feature = "rust1", since = "1.0.0")]
745753
fn fmt(&self, f: &mut Formatter<'_>) -> Result;

0 commit comments

Comments
 (0)
Failed to load comments.