pub struct Error;
Expand description
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§
1.11.0 · Source§impl Error for Error
impl Error for Error
Source§fn description(&self) -> &str
fn description(&self) -> &str
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§impl Ord for Error
impl Ord for Error
1.0.0 · Source§impl PartialOrd for Error
impl PartialOrd for Error
impl Copy for Error
impl Eq for Error
impl StructuralPartialEq 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 UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoAnyhow for T
impl<T> IntoAnyhow for T
Source§fn into_anyhow(self) -> Error
fn into_anyhow(self) -> Error
self
into an anyhow::Error
.