#[derive(Debug, thiserror::Error)] #[error("missing field '{0}'")] pub struct FieldErr(pub &'static str); pub type Field = Result; // TODO this trait is really ad-hoc and has awful naming... pub trait OptionalString { fn str(self) -> Option; } impl OptionalString for Field<&str> { fn str(self) -> Option { self.ok().map(|x| x.to_string()) } }