diff options
author | sterlingjensen <5555776+sterlingjensen@users.noreply.github.com> | 2020-01-02 18:17:22 -0600 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2020-01-03 00:17:22 +0000 |
commit | 05df4f4dbabd82bc71cea6b81ee9383a55b32088 (patch) | |
tree | 839acbe3cde075efbd06449e65521b58b093a18d /alacritty/src/display.rs | |
parent | d774c7f3a3466b6d7dbcce4c149d74c041036c9f (diff) | |
download | r-alacritty-05df4f4dbabd82bc71cea6b81ee9383a55b32088.tar.gz r-alacritty-05df4f4dbabd82bc71cea6b81ee9383a55b32088.tar.bz2 r-alacritty-05df4f4dbabd82bc71cea6b81ee9383a55b32088.zip |
Replace deprecated Error methods
Diffstat (limited to 'alacritty/src/display.rs')
-rw-r--r-- | alacritty/src/display.rs | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/alacritty/src/display.rs b/alacritty/src/display.rs index 5e800ed5..0b1a64a0 100644 --- a/alacritty/src/display.rs +++ b/alacritty/src/display.rs @@ -15,7 +15,7 @@ //! The display subsystem including window management, font rasterization, and //! GPU drawing. use std::f64; -use std::fmt; +use std::fmt::{self, Formatter}; use std::time::Instant; use glutin::dpi::{PhysicalPosition, PhysicalSize}; @@ -61,56 +61,47 @@ pub enum Error { } impl std::error::Error for Error { - fn cause(&self) -> Option<&dyn (std::error::Error)> { - match *self { - Error::Window(ref err) => Some(err), - Error::Font(ref err) => Some(err), - Error::Render(ref err) => Some(err), - Error::ContextError(ref err) => Some(err), - } - } - - fn description(&self) -> &str { - match *self { - Error::Window(ref err) => err.description(), - Error::Font(ref err) => err.description(), - Error::Render(ref err) => err.description(), - Error::ContextError(ref err) => err.description(), + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Window(err) => err.source(), + Error::Font(err) => err.source(), + Error::Render(err) => err.source(), + Error::ContextError(err) => err.source(), } } } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self { - Error::Window(ref err) => err.fmt(f), - Error::Font(ref err) => err.fmt(f), - Error::Render(ref err) => err.fmt(f), - Error::ContextError(ref err) => err.fmt(f), + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match self { + Error::Window(err) => err.fmt(f), + Error::Font(err) => err.fmt(f), + Error::Render(err) => err.fmt(f), + Error::ContextError(err) => err.fmt(f), } } } impl From<window::Error> for Error { - fn from(val: window::Error) -> Error { + fn from(val: window::Error) -> Self { Error::Window(val) } } impl From<font::Error> for Error { - fn from(val: font::Error) -> Error { + fn from(val: font::Error) -> Self { Error::Font(val) } } impl From<renderer::Error> for Error { - fn from(val: renderer::Error) -> Error { + fn from(val: renderer::Error) -> Self { Error::Render(val) } } impl From<glutin::ContextError> for Error { - fn from(val: glutin::ContextError) -> Error { + fn from(val: glutin::ContextError) -> Self { Error::ContextError(val) } } @@ -241,7 +232,7 @@ impl Display { _ => (), } - Ok(Display { + Ok(Self { window, renderer, glyph_cache, |