use anyhow::Result; pub trait Traverse { fn traverse(self, f: impl FnOnce(T) -> Result) -> Result>; } impl Traverse for Option { fn traverse(self, f: impl FnOnce(T) -> Result) -> Result> { self.map_or(Ok(None), |value| f(value).map(Some)) } }