This is my code (XMLElement
from xml-builder):
use anyhow::Result;
use xml_builder::XMLElement;
fn foo() -> Result<()> {
let mut v = XMLElement::new("v");
v.add_child(XMLElement::new("e"))?;
Ok(())
}
It doesn't compile:
error[E0277]: the trait bound `XMLError: StdError` is not satisfied
--> src/xml.rs:78:41
|
78 | v.add_child(XMLElement::new("e"))?;
| ^ the trait `StdError` is not implemented for `XMLError`
|
= help: the following other types implement trait `FromResidual<R>`:
<Result<T, F> as FromResidual<Result<Infallible, E>>>
<Result<T, F> as FromResidual<Yeet<E>>>
= note: required for `anyhow::Error` to implement `From<XMLError>`
= note: required for `Result<std::string::String, anyhow::Error>` to implement `FromResidual<Result<Infallible, XMLError>>`
How to I map XMLError
to anyhow::Error
? I tried .map_err(|e| anyhow::Error::new(e))
, but it doesn't work either.