diff options
Diffstat (limited to 'font/src/ft/mod.rs')
-rw-r--r-- | font/src/ft/mod.rs | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs index 431a5004..206d6042 100644 --- a/font/src/ft/mod.rs +++ b/font/src/ft/mod.rs @@ -15,7 +15,7 @@ //! Rasterization powered by FreeType and FontConfig use std::cmp::{min, Ordering}; use std::collections::HashMap; -use std::fmt; +use std::fmt::{self, Display, Formatter}; use std::path::PathBuf; use freetype::freetype_sys; @@ -46,7 +46,7 @@ struct Face { } impl fmt::Debug for Face { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { f.debug_struct("Face") .field("ft_face", &self.ft_face) .field("key", &self.key) @@ -668,32 +668,23 @@ pub enum Error { } impl std::error::Error for Error { - fn cause(&self) -> Option<&dyn std::error::Error> { - match *self { - Error::FreeType(ref err) => Some(err), + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::FreeType(err) => err.source(), _ => None, } } - - fn description(&self) -> &str { - match *self { - Error::FreeType(ref err) => err.description(), - Error::MissingFont(ref _desc) => "Couldn't find the requested font", - Error::FontNotLoaded => "Tried to operate on font that hasn't been loaded", - Error::MissingSizeMetrics => "Tried to get size metrics from a face without a size", - } - } } -impl std::fmt::Display for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - match *self { - Error::FreeType(ref err) => err.fmt(f), - Error::MissingFont(ref desc) => write!( +impl Display for Error { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + Error::FreeType(err) => err.fmt(f), + Error::MissingFont(err) => write!( f, "Couldn't find a font with {}\n\tPlease check the font config in your \ alacritty.yml.", - desc + err ), Error::FontNotLoaded => f.write_str("Tried to use a font that hasn't been loaded"), Error::MissingSizeMetrics => { |