mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-11-24 06:18:44 +01:00
chore: appease clippy
This commit is contained in:
parent
c4207af8da
commit
de9ca81b65
|
@ -40,10 +40,13 @@ pub(super) fn find_config_file() -> Result<PathBuf, ConfigError> {
|
||||||
|
|
||||||
impl Configs {
|
impl Configs {
|
||||||
pub fn read(p: PathBuf) -> Result<Self, ConfigError> {
|
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("ron") => Ok(serde_json::from_str(&fs::read_to_string(p)?)?),
|
||||||
Some("json") => Ok(ron::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;
|
use ron::error::Position;
|
||||||
|
|
||||||
/// Report an `Error` from the `serde_json` crate
|
/// 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_serde_err(src, err.line(), err.column(), err.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Report a `SpannedError` from the `ron` crate
|
/// 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;
|
let Position { line, col } = err.position;
|
||||||
report_serde_err(src, line, col, err.to_string())
|
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_message(msg)
|
||||||
.with_note("We'd like to give better errors, but serde errors are horrible to work with...")
|
.with_note("We'd like to give better errors, but serde errors are horrible to work with...")
|
||||||
.finish()
|
.finish()
|
||||||
.print(("test", Source::from(src)))
|
.eprint(("test", Source::from(src)))
|
||||||
.unwrap();
|
.expect("writing error to stderr failed");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue