orphanage 0.5.6

Random collection of stuff that is still searching for a home.
Documentation
use std::{fmt, io};

#[derive(Debug)]
pub enum Error {
  BadFormat(String),
  IO(String)
}

impl Error {
  #[allow(clippy::needless_pass_by_value)]
  pub fn bad_format<S: ToString>(s: S) -> Self {
    Self::BadFormat(s.to_string())
  }
}

impl std::error::Error for Error {}

impl From<io::Error> for Error {
  fn from(err: io::Error) -> Self {
    Self::IO(err.to_string())
  }
}

impl fmt::Display for Error {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    match self {
      Self::BadFormat(s) => {
        write!(f, "Bad format error; {s}")
      }
      Self::IO(s) => {
        write!(f, "I/O error; {s}")
      }
    }
  }
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :