use core::fmt;
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
#[non_exhaustive]
pub struct LostError(Option<&'static str>);
#[cfg(feature = "unstable-error")]
impl core::error::Error for LostError {}
impl fmt::Display for LostError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("destination lost")?;
if let Some(message) = self.0 {
f.write_str(", ")?;
f.write_str(message)?;
}
Ok(())
}
}
impl LostError {
pub fn new() -> Self {
Self(None)
}
pub fn from_message(message: &'static str) -> Self {
Self(Some(message))
}
pub fn message(&self) -> Option<&'static str> {
self.0
}
}