- I have the following code:
use super::*;
#[derive(Debug, Clone)]
pub enum ForestAuxErr<NodeID: Clone + Eq + Hash, AuxErr: Clone> {
ForestErr(ForestErr<NodeID>),
AuxErr(AuxErr),
}
pub trait ForestAuxErrT<NodeID> {
fn missing_child(node_id: NodeID) -> Self;
}
impl<NodeID: Clone + Eq + Hash, AuxErr: Clone> From<AuxErr> for ForestAuxErr<NodeID, AuxErr> {
fn from(aux_error: AuxErr) -> ForestAuxErr<NodeID, AuxErr> {
ForestAuxErr::AuxErr(aux_error)
}
}
impl<NodeID: Clone + Eq + Hash, AuxErr: Clone> From<ForestErr<NodeID>>
for ForestAuxErr<NodeID, AuxErr>
{
fn from(forest_error: ForestErr<NodeID>) -> ForestAuxErr<NodeID, AuxErr> {
ForestAuxErr::ForestErr(forest_error)
}
}
- I get an error of:
13 | impl<NodeID: Clone + Eq + Hash, AuxErr: Clone> From<AuxErr> for ForestAuxErr<NodeID, AuxErr> {
| -------------------------------------------------------------------------------------------- first implementation here
...
19 | / impl<NodeID: Clone + Eq + Hash, AuxErr: Clone> From<ForestErr<NodeID>>
20 | | for ForestAuxErr<NodeID, AuxErr>
21 | | {
22 | | fn from(forest_error: ForestErr<NodeID>) -> ForestAuxErr<NodeID, AuxErr> {
23 | | ForestAuxErr::ForestErr(forest_error)
24 | | }
25 | | }
| |_^ conflicting implementation for `forest::forest_aux_error::ForestAuxErr<_, forest::forest_error::ForestErr<_>>`
-
I am not sure how to fix this.
-
The XY problem is that I have a number of functions that return
Result<_, Error>
and I want auto conversion of errors on?