Struct Error

pub struct Error;

The error type which is returned from formatting a message into a stream.

This type does not support transmission of an error other than that an error occurred. This is because, despite the existence of this error, string formatting is considered an infallible operation. fmt() implementors should not return this Error unless they received it from their Formatter. The only time your code should create a new instance of this error is when implementing fmt::Write, in order to cancel the formatting operation when writing to the underlying stream fails.

Any extra information must be arranged to be transmitted through some other means, such as storing it in a field to be consulted after the formatting operation has been cancelled. (For example, this is how std::io::Write::write_fmt() propagates IO errors during writing.)

This type, fmt::Error, should not be confused with std::io::Error or std::error::Error, which you may also have in scope.

Examples

use std::fmt::{self, write};

let mut output = String::new();
if let Err(fmt::Error) = write(&mut output, format_args!("Hello {}!", "world")) {
    panic!("An error occurred");
}

Trait Implementations

impl Clone for Error

fn clone(&self) -> Self

impl Copy for Error

impl Debug for Error

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

impl Default for Error

fn default() -> Self

impl Display for Error

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

impl Eq for Error

impl Error for Error

impl Hash for Error

fn hash<__H: Hasher>(&self, state: &mut __H)

impl Ord for Error

fn cmp(&self, other: &Self) -> Ordering

impl PartialEq for Error

fn eq(&self, other: &Self) -> bool

impl PartialOrd for Error

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

impl StructuralPartialEq for Error

impl TrivialClone for Error

Auto Trait Implementations

impl Freeze for Error

impl RefUnwindSafe for Error

impl Send for Error

impl Sync for Error

impl Unpin for Error

impl UnsafeUnpin for Error

impl UnwindSafe for Error

Blanket Implementations

impl<T> Any for Error where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Error where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Error where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Error where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Error

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Printable for Error where T: Copy + Debug,

impl<T> SizeHint for Error where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Error

impl<T, U> Into<U> for Error where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Error where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Error where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>