Skip to content

Commit d5985e3

Browse files
committed
remove InitError because only one variant was used
1 parent c4e74c7 commit d5985e3

File tree

2 files changed

+3
-32
lines changed

2 files changed

+3
-32
lines changed

src/sdl2/ttf/context.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -91,41 +91,14 @@ pub fn get_linked_version() -> Version {
9191
Version::from_ll(unsafe { *ttf::TTF_Linked_Version() })
9292
}
9393

94-
/// An error for when `sdl2_ttf` is attempted initialized twice
95-
/// Necessary for context management, unless we find a way to have a singleton
96-
#[derive(Debug)]
97-
pub enum InitError {
98-
InitializationError(String),
99-
AlreadyInitializedError,
100-
}
101-
102-
impl error::Error for InitError {
103-
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
104-
match *self {
105-
InitError::InitializationError(_) | InitError::AlreadyInitializedError => None,
106-
}
107-
}
108-
}
109-
110-
impl fmt::Display for InitError {
111-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
112-
match self {
113-
Self::AlreadyInitializedError => {
114-
write!(f, "SDL2_TTF has already been initialized")
115-
}
116-
Self::InitializationError(error) => write!(f, "SDL2_TTF initialization error: {error}"),
117-
}
118-
}
119-
}
120-
12194
/// Initializes the truetype font API and returns a context manager which will
12295
/// clean up the library once it goes out of scope.
12396
#[doc(alias = "TTF_Init")]
124-
pub fn init() -> Result<Sdl2TtfContext, InitError> {
97+
pub fn init() -> Result<Sdl2TtfContext, String> {
12598
if unsafe { ttf::TTF_Init() } == 0 {
12699
Ok(Sdl2TtfContext(()))
127100
} else {
128-
Err(InitError::InitializationError(get_error()))
101+
Err(get_error())
129102
}
130103
}
131104

src/sdl2/ttf/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
mod context;
2424
mod font;
2525

26-
pub use self::context::{
27-
get_linked_version, has_been_initialized, init, InitError, Sdl2TtfContext,
28-
};
26+
pub use self::context::{get_linked_version, has_been_initialized, init, Sdl2TtfContext};
2927
pub use self::font::{
3028
Font, FontError, FontResult, FontStyle, GlyphMetrics, Hinting, PartialRendering,
3129
};

0 commit comments

Comments
 (0)