# Trait alloc::fmt::Display
1.0.0[−][src]

    pub trait Display {
        fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
    }

Expand description

Format trait for an empty format, `{}`.

`Display` is similar to `Debug`, but `Display` is for user-facing output, and so cannot be derived.

For more information on formatters, see the module-level documentation.

## Examples

Implementing `Display` on a type:

    use std::fmt;

    struct Point {
        x: i32,
        y: i32,
    }

    impl fmt::Display for Point {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            write!(f, "({}, {})", self.x, self.y)
        }
    }

    let origin = Point { x: 0, y: 0 };

    assert_eq!(format!("The origin is: {}", origin), "The origin is: (0, 0)");

Run

## Required methods

[src]

#### fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.

##### Examples

    use std::fmt;

    struct Position {
        longitude: f32,
        latitude: f32,
    }

    impl fmt::Display for Position {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            write!(f, "({}, {})", self.longitude, self.latitude)
        }
    }

    assert_eq!("(1.987, 2.983)",
               format!("{}", Position { longitude: 1.987, latitude: 2.983, }));

Run

## Implementations on Foreign Types

[src]

### impl<'_, T> Display for &'_ mut T where
T: Display + ?Sized,

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for ParseFloatError

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for NonZeroI128

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.16.0[src]

### impl Display for EscapeDefault

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for NonZeroI8

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for f32

[src]

#### pub fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

1.20.0[src]

### impl Display for ParseCharError

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.26.0[src]

### impl<'_> Display for Location<'_>

[src]

#### pub fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

1.13.0[src]

### impl Display for BorrowError

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.39.0[src]

### impl Display for EscapeDefault

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for u32

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for ParseIntError

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for u64

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for u8

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.16.0[src]

### impl Display for ToLowercase

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.28.0[src]

### impl Display for NonZeroU32

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.9.0[src]

### impl Display for DecodeUtf16Error

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for NonZeroI32

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.16.0[src]

### impl Display for ToUppercase

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for u16

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for CharTryFromError

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.33.0[src]

### impl<P> Display for Pin<P> where
P: Display,

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for u128

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.28.0[src]

### impl Display for NonZeroU128

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl<'a> Display for EscapeAscii<'a>

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl<'_, T> Display for &'_ T where
T: Display + ?Sized,

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.28.0[src]

### impl Display for NonZeroU64

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for isize

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for FromSecsError

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for NonZeroIsize

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for NonZeroI64

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.10.0[src]

### impl<T> Display for Wrapping<T> where
T: Display,

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.20.0[src]

### impl<'_, T> Display for RefMut<'_, T> where
T: Display + ?Sized,

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for NonZeroI16

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for bool

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for char

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.28.0[src]

### impl Display for NonZeroU16

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.20.0[src]

### impl<'_, T> Display for Ref<'_, T> where
T: Display + ?Sized,

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for usize

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for !

[src]

#### pub fn fmt(&self, &mut Formatter<'_>) -> Result<(), Error>

1.26.0[src]

### impl<'_> Display for PanicInfo<'_>

[src]

#### pub fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl<T> Display for Saturating<T> where
T: Display,

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for i128

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.13.0[src]

### impl Display for BorrowMutError

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.36.0[src]

### impl Display for TryFromSliceError

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for i8

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for i32

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.28.0[src]

### impl Display for NonZeroU8

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.28.0[src]

### impl Display for NonZeroUsize

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.16.0[src]

### impl Display for EscapeUnicode

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for Infallible

[src]

#### pub fn fmt(&self, &mut Formatter<'_>) -> Result<(), Error>

1.20.0[src]

### impl Display for EscapeDebug

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for f64

[src]

#### pub fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for Utf8Lossy

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for i64

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for str

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

[src]

### impl Display for i16

[src]

#### pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

1.34.0[src]

### impl Display for TryFromIntError

[src]

#### pub fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

## Implementors

[src]

### impl Display for AllocError

1.28.0[src]

### impl Display for LayoutError

1.57.0[src]

### impl Display for TryReserveError

[src]

### impl Display for ParseBoolError

[src]

### impl Display for Utf8Error

[src]

### impl Display for FromUtf8Error

[src]

### impl Display for FromUtf16Error

[src]

### impl Display for String

[src]

### impl Display for Error

[src]

### impl<'_> Display for Arguments<'_>

1.34.0[src]

### impl<'a> Display for alloc::str::EscapeDebug<'a>

1.34.0[src]

### impl<'a> Display for alloc::str::EscapeDefault<'a>

1.34.0[src]

### impl<'a> Display for alloc::str::EscapeUnicode<'a>

[src]

### impl<'a, K: Debug + Ord, V: Debug> Display for OccupiedError<'a, K, V>

[src]

### impl<B: ?Sized> Display for Cow<'_, B> where
B: Display + ToOwned<Owned: Display>,

[src]

### impl<T: Display + ?Sized, A: Allocator> Display for Box<T, A>

[src]

### impl<T: ?Sized + Display> Display for Rc<T>

[src]

### impl<T: ?Sized + Display> Display for Arc<T>