3 ms·
Author of `wherr` here. Thanks for sharing a really nice alternative solution to the problem, I like it! It seems to be a bit faster: running 2 tests test test
by JoelJacobson 3y ago
Author of `wherr` here. Thanks for sharing a really nice alternative solution to the problem, I like it!
It seems to be a bit faster:
running 2 tests
test tests::benchmark_location_caller ... bench: 15 ns/iter (+/- 0)
test tests::benchmark_wherr ... bench: 18 ns/iter (+/- 1)
I also like that it's more explicit; the actual error type is then spelled out, instead of being magically wrapped by the macro, that's nice!
Sounds like a better approach overall, but I'm curious to understand more about the disadvantage you mention, the problem with using `#[track_caller]`, that then masquerades the actually error line number. For my own code, I can of course control that and just ensure I don't make use of `#[track_caller]` anywhere in my code. But if other crates would be making use of `#[track_caller]`, that would prevent getting the correct error line.
Can anything be said about how common it is to use `#[track_caller]` in crates? If very uncommon, then I can live with it. But it would be annoying if it works sometimes and other times not.