Skip to content

Commit

Permalink
Rollup merge of rust-lang#127363 - GuillaumeGomez:improve-fmt-code-re…
Browse files Browse the repository at this point in the history
…adability, r=Amanieu

Improve readability of some fmt code examples

Some indent was weird. Some examples were too long (overall better to keep it to maximum 80 columns, but only changed the most outstanding ones).

r? ```@Amanieu```
  • Loading branch information
compiler-errors authored Jul 6, 2024
2 parents 3eeca5f + 2fcdebb commit ad4fde6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,10 @@ impl Display for Arguments<'_> {
///
/// let origin = Point { x: 0, y: 0 };
///
/// assert_eq!(format!("The origin is: {origin:?}"), "The origin is: Point { x: 0, y: 0 }");
/// assert_eq!(
/// format!("The origin is: {origin:?}"),
/// "The origin is: Point { x: 0, y: 0 }",
/// );
/// ```
///
/// Manually implementing:
Expand All @@ -541,7 +544,10 @@ impl Display for Arguments<'_> {
///
/// let origin = Point { x: 0, y: 0 };
///
/// assert_eq!(format!("The origin is: {origin:?}"), "The origin is: Point { x: 0, y: 0 }");
/// assert_eq!(
/// format!("The origin is: {origin:?}"),
/// "The origin is: Point { x: 0, y: 0 }",
/// );
/// ```
///
/// There are a number of helper methods on the [`Formatter`] struct to help you with manual
Expand Down Expand Up @@ -582,11 +588,11 @@ impl Display for Arguments<'_> {
///
/// let origin = Point { x: 0, y: 0 };
///
/// assert_eq!(format!("The origin is: {origin:#?}"),
/// "The origin is: Point {
/// let expected = "The origin is: Point {
/// x: 0,
/// y: 0,
/// }");
/// }";
/// assert_eq!(format!("The origin is: {origin:#?}"), expected);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -738,8 +744,10 @@ pub trait Display {
/// }
/// }
///
/// assert_eq!("(1.987, 2.983)",
/// format!("{}", Position { longitude: 1.987, latitude: 2.983, }));
/// assert_eq!(
/// "(1.987, 2.983)",
/// format!("{}", Position { longitude: 1.987, latitude: 2.983, }),
/// );
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
Expand Down

0 comments on commit ad4fde6

Please sign in to comment.