Skip to content

Instantly share code, notes, and snippets.

@shadowmint
Created January 27, 2015 04:35
Show Gist options
  • Save shadowmint/923ed7a5c21da552386f to your computer and use it in GitHub Desktop.
Save shadowmint/923ed7a5c21da552386f to your computer and use it in GitHub Desktop.
enum PlayerError {
InvalidCodec(String),
InvalidMedia,
}
impl std::fmt::Display for PlayerError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
use self::PlayerError::*;
let s = match *self {
InvalidCodec(ref s) => format!("Invalid codec: {}", s).clone(),
InvalidMedia => String::from_str("Unable to decode media"),
};
std::fmt::Display::fmt(s.as_slice(), f)
}
}
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment