Removed the use of strings in the MainError Debug implementation
Browse files
+10 −11 src/errors.rs
| @@ -193,21 +193,20 @@ impl std::fmt::Debug for MainError { | |||
| 193 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | 193 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { |
| 194 | use MainError::*; | 194 | use MainError::*; |
| 195 | 195 | ||
| 196 | - let message = match self { | 196 | + match self { |
| 197 | CouldNotCreateConfigDir(e) | 197 | CouldNotCreateConfigDir(e) |
| 198 | | CouldNotWriteConfig(e) | 198 | | CouldNotWriteConfig(e) |
| 199 | | FailedCheckExist(e) | 199 | | FailedCheckExist(e) |
| 200 | | FailedReadConfig(e) => { | 200 | | FailedReadConfig(e) => { |
| 201 | - format!("{e}") | 201 | + write!(f, "{e}") |
| 202 | } | 202 | } |
| 203 | - FailedReadConfigTemplate(e) => format!("{e}"), | 203 | + FailedReadConfigTemplate(e) => write!(f, "{e}"), |
| 204 | - CouldNotStartWm(e) | BadRestartStatus(e) => format!("{e}"), | 204 | + CouldNotStartWm(e) | BadRestartStatus(e) => write!(f, "{e}"), |
| 205 | - BadConfigPath => "Given config path does not exist".to_string(), | 205 | + BadConfigPath => write!(f, "Given config path does not exist"), |
| 206 | - NoConfigPath => "The --config switch requires a path value".to_string(), | 206 | + NoConfigPath => write!(f, "The --config switch requires a path value"), |
| 207 | - InvalidArguments => "The arguments given are invalid try --help".to_string(), | 207 | + InvalidArguments => write!(f, "The arguments given are invalid try --help"), |
| 208 | - NoProgramName => "Could not get the program name from the environment".to_string(), | 208 | + NoProgramName => write!(f, "Could not get the program name from the environment"), |
| 209 | - NoConfigDir => "Could not get the config dir".to_string(), | 209 | + NoConfigDir => write!(f, "Could not get the config dir"), |
| 210 | - }; | 210 | + } |
| 211 | - write!(f, "{message}") | ||
| 212 | } | 211 | } |
| 213 | } | 212 | } |