From 67c99f18012371bbe0cc7e46bb9eb7f7fe9dd7ca Mon Sep 17 00:00:00 2001 From: Kyle Strohbeck Date: Fri, 9 Dec 2016 13:11:42 -0600 Subject: [PATCH] Implement Display for PrefPathError. --- src/sdl2/filesystem.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/sdl2/filesystem.rs b/src/sdl2/filesystem.rs index a99636b1..77c21c45 100644 --- a/src/sdl2/filesystem.rs +++ b/src/sdl2/filesystem.rs @@ -1,4 +1,5 @@ use std::ffi::{CStr, CString, NulError}; +use std::fmt; use get_error; use libc::c_char; @@ -24,6 +25,18 @@ pub enum PrefPathError { SdlError(String), } +impl fmt::Display for PrefPathError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::PrefPathError::*; + + match *self { + InvalidOrganizationName(ref e) => write!(f, "Invalid organization name: {}", e), + InvalidApplicationName(ref e) => write!(f, "Invalid application name: {}", e), + SdlError(ref e) => write!(f, "SDL error: {}", e) + } + } +} + // TODO: Change to OsStr or something? /// Return the preferred directory for the application to write files on this /// system, based on the given organization and application name.