Skip to content

Commit

Permalink
fix(warn): remove the deprecated function
Browse files Browse the repository at this point in the history
    use of deprecated method `std::error::Error::description`:
    use the Display impl or to_string()
  • Loading branch information
ZengGengSen committed Feb 2, 2024
1 parent d8427ff commit fb230e4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
9 changes: 1 addition & 8 deletions src/sdl2/ttf/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,7 @@ pub enum InitError {
AlreadyInitializedError,
}

impl error::Error for InitError {
fn description(&self) -> &str {
match *self {
InitError::AlreadyInitializedError => "SDL2_TTF has already been initialized",
InitError::InitializationError(ref error) => error.description(),
}
}

impl error::Error for InitError {
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
InitError::AlreadyInitializedError => None,
Expand Down
10 changes: 1 addition & 9 deletions src/sdl2/ttf/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use get_error;
use pixels::Color;
use rwops::RWops;
use std::error;
use std::error::Error;
use std::ffi::NulError;
use std::ffi::{CStr, CString};
use std::fmt;
Expand Down Expand Up @@ -58,13 +57,6 @@ pub enum FontError {
}

impl error::Error for FontError {
fn description(&self) -> &str {
match *self {
FontError::InvalidLatin1Text(ref error) => error.description(),
FontError::SdlError(ref message) => message,
}
}

fn cause(&self) -> Option<&dyn error::Error> {
match *self {
FontError::InvalidLatin1Text(ref error) => Some(error),
Expand All @@ -77,7 +69,7 @@ impl fmt::Display for FontError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
FontError::InvalidLatin1Text(ref err) => {
write!(f, "Invalid Latin-1 bytes: {}", err.description())
write!(f, "Invalid Latin-1 bytes: {}", err)
}
FontError::SdlError(ref msg) => {
write!(f, "SDL2 error: {}", msg)
Expand Down

0 comments on commit fb230e4

Please sign in to comment.