darling icon indicating copy to clipboard operation
darling copied to clipboard

Convert errors in Accumulator::handle

Open DCNick3 opened this issue 2 years ago • 4 comments

Currently, Accumulator::handle accepts a darling::Result<T>. This doesn't play nice when using it with non-darling errors (for example, to handle syn error one has to write:

let parsed = accumulator.handle(syn::parse2(tokens).map_err(Into::into));

If Accumulator::handle wound accept Result<T, E> where E: Into<darling::Error>, it would allow to handle other errors without explicit conversion, the same way the ? operator works

DCNick3 avatar Aug 03 '23 14:08 DCNick3

@ijackson do you recall if there was a reason we didn't do this before? Was it causing problems with type inference?

TedDriggs avatar Aug 07 '23 15:08 TedDriggs

I don't think so. I think handle_in would have such problems with inference, since typically the closure would want to use ?, leading to double-into. I suspect we just didn't consider the two cases separately.

ijackson avatar Aug 07 '23 16:08 ijackson

If someone makes an MR branch, I can do experimental builds of derive-builder (and derive-builder-fork-arti) to see what the impact seems to be in practice.

ijackson avatar Aug 07 '23 16:08 ijackson

@DCNick3 can you make a PR with that change for @ijackson to test against?

TedDriggs avatar Oct 16 '23 15:10 TedDriggs