backtrace-rs icon indicating copy to clipboard operation
backtrace-rs copied to clipboard

`trace` should be `unsafe fn(cb: impl FnMut(&Frame) -> ControlFlow)`

Open workingjubilee opened this issue 10 months ago • 2 comments

The war on bool will continue.

And thus we should use ControlFlow::Break to indicate forward progress should be stopped in backtrace's $(($MAJOR+1)) version.

workingjubilee avatar Apr 11 '24 02:04 workingjubilee

Obviously this change is somewhat gratuitous, so if anyone has some strong opinions otherwise, I'm listening. However, it's really important for an unsafe interface to be very clear, so...

workingjubilee avatar Apr 11 '24 02:04 workingjubilee

I do think this make sense to me. trace is indeed just a loop in fancy clothing so ControlFlow is the most correct type, Correctness is important and, as you say, that's especially true in unsafe code.

This may not be the most crucial change in the world but if we're looking at ways to improve the API then this should be one of them.

ChrisDenton avatar Apr 11 '24 16:04 ChrisDenton