Always use f as the argument name for &mut std::fmt::Formatter (#1023)

This commit is contained in:
Felix Rabe 2019-07-09 23:49:07 +02:00 committed by Osspial
parent f5c624bcd6
commit 3ee59696e5
5 changed files with 22 additions and 23 deletions

View file

@ -48,8 +48,8 @@ macro_rules! os_error {
} }
impl fmt::Display for OsError { impl fmt::Display for OsError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
formatter.pad(&format!( f.pad(&format!(
"os error at {}:{}: {}", "os error at {}:{}: {}",
self.file, self.line, self.error self.file, self.line, self.error
)) ))
@ -57,23 +57,23 @@ impl fmt::Display for OsError {
} }
impl fmt::Display for ExternalError { impl fmt::Display for ExternalError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self { match self {
ExternalError::NotSupported(e) => e.fmt(formatter), ExternalError::NotSupported(e) => e.fmt(f),
ExternalError::Os(e) => e.fmt(formatter), ExternalError::Os(e) => e.fmt(f),
} }
} }
} }
impl fmt::Debug for NotSupportedError { impl fmt::Debug for NotSupportedError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
formatter.debug_struct("NotSupportedError").finish() f.debug_struct("NotSupportedError").finish()
} }
} }
impl fmt::Display for NotSupportedError { impl fmt::Display for NotSupportedError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
formatter.pad("the requested operation is not supported by Winit") f.pad("the requested operation is not supported by Winit")
} }
} }

View file

@ -46,14 +46,14 @@ pub struct EventLoopWindowTarget<T: 'static> {
} }
impl<T> fmt::Debug for EventLoop<T> { impl<T> fmt::Debug for EventLoop<T> {
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmtr.pad("EventLoop { .. }") f.pad("EventLoop { .. }")
} }
} }
impl<T> fmt::Debug for EventLoopWindowTarget<T> { impl<T> fmt::Debug for EventLoopWindowTarget<T> {
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmtr.pad("EventLoopWindowTarget { .. }") f.pad("EventLoopWindowTarget { .. }")
} }
} }
@ -189,8 +189,8 @@ impl<T: 'static> EventLoopProxy<T> {
} }
impl<T: 'static> fmt::Debug for EventLoopProxy<T> { impl<T: 'static> fmt::Debug for EventLoopProxy<T> {
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmtr.pad("EventLoopProxy { .. }") f.pad("EventLoopProxy { .. }")
} }
} }

View file

@ -28,7 +28,7 @@ pub enum BadIcon {
} }
impl fmt::Display for BadIcon { impl fmt::Display for BadIcon {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let msg = match self { let msg = match self {
&BadIcon::ByteCountNotDivisibleBy4 { byte_count } => format!( &BadIcon::ByteCountNotDivisibleBy4 { byte_count } => format!(
"The length of the `rgba` argument ({:?}) isn't divisible by 4, making it impossible to interpret as 32bpp RGBA pixels.", "The length of the `rgba` argument ({:?}) isn't divisible by 4, making it impossible to interpret as 32bpp RGBA pixels.",
@ -44,7 +44,7 @@ impl fmt::Display for BadIcon {
width, height, pixel_count, width_x_height, width, height, pixel_count, width_x_height,
), ),
}; };
write!(formatter, "{}", msg) write!(f, "{}", msg)
} }
} }

View file

@ -264,9 +264,8 @@ struct EventLoopHandler<F, T: 'static> {
} }
impl<F, T: 'static> Debug for EventLoopHandler<F, T> { impl<F, T: 'static> Debug for EventLoopHandler<F, T> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter f.debug_struct("EventLoopHandler")
.debug_struct("EventLoopHandler")
.field("event_loop", &self.event_loop) .field("event_loop", &self.event_loop)
.finish() .finish()
} }

View file

@ -55,10 +55,10 @@ pub enum OsError {
} }
impl fmt::Display for OsError { impl fmt::Display for OsError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self { match self {
OsError::XError(e) => formatter.pad(&e.description), OsError::XError(e) => f.pad(&e.description),
OsError::XMisc(e) => formatter.pad(e), OsError::XMisc(e) => f.pad(e),
} }
} }
} }