snafu
snafu copied to clipboard
Cannot use lifetime-parameterized errors as sources
Code like this won’t work:
#[derive(Debug, Snafu)]
enum Error<T> {
Generic { source: GenericError<‘a, T> },
}
We need a reference with the ’static
bound to be able to call Error::source
.
We could perhaps disable the ability to call Error::source
by just returning None
.
Could not Snafu also conditionally supports error types as:
#derive(Debug, Snafu)
enum Error<T> {
Foo{ source: T}
}
I suppose it could be done by detecting that a source depend on a generic parameter and
then, for each struct/trait generated by snafu add a WherePredicate T: 'static + Error
That certainly seems like an avenue worth pursuing! Sometimes the compiler errors arising from conditional implementations are hard to decipher though.