From d5985e36907ccffee4d2423b234206e10a6c9409 Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Tue, 8 Oct 2024 17:45:30 +0200 Subject: [PATCH] remove `InitError` because only one variant was used --- src/sdl2/ttf/context.rs | 31 ++----------------------------- src/sdl2/ttf/mod.rs | 4 +--- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/src/sdl2/ttf/context.rs b/src/sdl2/ttf/context.rs index 2f713c1949b..2da29b632ce 100644 --- a/src/sdl2/ttf/context.rs +++ b/src/sdl2/ttf/context.rs @@ -91,41 +91,14 @@ pub fn get_linked_version() -> Version { Version::from_ll(unsafe { *ttf::TTF_Linked_Version() }) } -/// An error for when `sdl2_ttf` is attempted initialized twice -/// Necessary for context management, unless we find a way to have a singleton -#[derive(Debug)] -pub enum InitError { - InitializationError(String), - AlreadyInitializedError, -} - -impl error::Error for InitError { - fn source(&self) -> Option<&(dyn error::Error + 'static)> { - match *self { - InitError::InitializationError(_) | InitError::AlreadyInitializedError => None, - } - } -} - -impl fmt::Display for InitError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::AlreadyInitializedError => { - write!(f, "SDL2_TTF has already been initialized") - } - Self::InitializationError(error) => write!(f, "SDL2_TTF initialization error: {error}"), - } - } -} - /// Initializes the truetype font API and returns a context manager which will /// clean up the library once it goes out of scope. #[doc(alias = "TTF_Init")] -pub fn init() -> Result { +pub fn init() -> Result { if unsafe { ttf::TTF_Init() } == 0 { Ok(Sdl2TtfContext(())) } else { - Err(InitError::InitializationError(get_error())) + Err(get_error()) } } diff --git a/src/sdl2/ttf/mod.rs b/src/sdl2/ttf/mod.rs index 2f9f02e38a5..6477c6d59f7 100644 --- a/src/sdl2/ttf/mod.rs +++ b/src/sdl2/ttf/mod.rs @@ -23,9 +23,7 @@ mod context; mod font; -pub use self::context::{ - get_linked_version, has_been_initialized, init, InitError, Sdl2TtfContext, -}; +pub use self::context::{get_linked_version, has_been_initialized, init, Sdl2TtfContext}; pub use self::font::{ Font, FontError, FontResult, FontStyle, GlyphMetrics, Hinting, PartialRendering, };