mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Implement Display for ShowMessageError.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user