Returned from Italy

This commit is contained in:
2025-07-18 16:29:52 +02:00
parent fe89188c4b
commit 19f2c6426a
17 changed files with 149 additions and 258 deletions

View File

@@ -1,4 +1,5 @@
use std::cell::RefCell;
use std::ffi::OsStr;
use std::fmt;
use std::ops::Add;
use std::sync::Arc;
@@ -177,6 +178,29 @@ pub fn mk_errv<I: Into<ErrPos>>(
mk_err(description, message, posv.into_iter().map_into()).into()
}
pub async fn async_io_err<I: Into<ErrPos>>(
err: async_std::io::Error,
i: &Interner,
posv: impl IntoIterator<Item = I>,
) -> OrcErrv {
mk_errv(i.i(&err.kind().to_string()).await, err.to_string(), posv)
}
pub async fn os_str_to_string<'a, I: Into<ErrPos>>(
str: &'a OsStr,
i: &Interner,
posv: impl IntoIterator<Item = I>,
) -> OrcRes<&'a str> {
match str.to_str() {
Some(str) => Ok(str),
None => Err(mk_errv(
i.i("Non-unicode string").await,
format!("{str:?} is not representable as unicode"),
posv,
)),
}
}
pub struct Reporter {
errors: RefCell<Vec<OrcErr>>,
}