Implement Display for ShowMessageError.

This commit is contained in:
Kyle Strohbeck
2016-12-09 13:19:59 -06:00
parent f272927b1e
commit 5f093e6482
+15
View File
@@ -1,4 +1,5 @@
use std::ffi::{CString, NulError};
use std::fmt;
use std::ptr;
use std::os::raw::{c_char,c_int};
@@ -81,6 +82,20 @@ pub enum ShowMessageError {
SdlError(String),
}
impl fmt::Display for ShowMessageError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::ShowMessageError::*;
match *self {
InvalidTitle(ref e) => write!(f, "Invalid title: {}", e),
InvalidMessage(ref e) => write!(f, "Invalid message: {}", e),
InvalidButton(ref e, value) => write!(f,
"Invalid button ({}): {}", value, e),
SdlError(ref e) => write!(f, "SDL error: {}", e)
}
}
}
/// Show a simple message box, meant to be informative only.
///
/// There is no way to know if the user clicked "Ok" or closed the message box,