mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-12-27 03:35:51 +01:00
chore: appease clippy
This commit is contained in:
parent
c4207af8da
commit
de9ca81b65
2 changed files with 9 additions and 6 deletions
|
@ -40,10 +40,13 @@ pub(super) fn find_config_file() -> Result<PathBuf, ConfigError> {
|
|||
|
||||
impl Configs {
|
||||
pub fn read(p: PathBuf) -> Result<Self, ConfigError> {
|
||||
match p.extension().map(|v| v.to_str().unwrap()) {
|
||||
match p
|
||||
.extension()
|
||||
.map(|v| v.to_str().expect("config path to be UTF-8"))
|
||||
{
|
||||
Some("ron") => Ok(serde_json::from_str(&fs::read_to_string(p)?)?),
|
||||
Some("json") => Ok(ron::from_str(&fs::read_to_string(p)?)?),
|
||||
e => Err(ConfigError::UnknownExtension(e.map(|v| v.to_owned()))),
|
||||
e => Err(ConfigError::UnknownExtension(e.map(str::to_string))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ use std::process;
|
|||
use ron::error::Position;
|
||||
|
||||
/// Report an `Error` from the `serde_json` crate
|
||||
pub fn report_serde_json_err(src: &str, err: serde_json::Error) -> ! {
|
||||
pub fn report_serde_json_err(src: &str, err: &serde_json::Error) -> ! {
|
||||
report_serde_err(src, err.line(), err.column(), err.to_string())
|
||||
}
|
||||
|
||||
/// Report a `SpannedError` from the `ron` crate
|
||||
pub fn report_serde_ron_err(src: &str, err: ron::error::SpannedError) -> ! {
|
||||
pub fn report_serde_ron_err(src: &str, err: &ron::error::SpannedError) -> ! {
|
||||
let Position { line, col } = err.position;
|
||||
report_serde_err(src, line, col, err.to_string())
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ fn report_serde_err(src: &str, line: usize, col: usize, msg: String) -> ! {
|
|||
.with_message(msg)
|
||||
.with_note("We'd like to give better errors, but serde errors are horrible to work with...")
|
||||
.finish()
|
||||
.print(("test", Source::from(src)))
|
||||
.unwrap();
|
||||
.eprint(("test", Source::from(src)))
|
||||
.expect("writing error to stderr failed");
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue