I've been away from embedded rust a while, and suddenly someone wrote the Embassy async runtime for embedded targets! Wow ... I mean WOW!
For fun and glory I want to understand this better, and make a minimal build, removing debug and trace-lines to see how compact a build I can produce.
I now have a build that can toggle a pin based on a timer, that take 4016 bytes, - quite pretty, but now I notice 'something' is leaking these text strings into the binary:
async fn` resumed after completion
assertion failed: n < 4
assertion failed: n < 32
It's not much ... but is there any way to avoid that?
This sounds like something that would come from the Future implementation that the compiler automatically generates for an async function. Those sorts of futures aren't designed to be polled again after they run to completion, so it triggers a panic.
I'm not sure how you would get rid of those strings, though.
Note that according to the documentation of Future, a different behavior would be conforming (and thus could be implemented by the compiler):
Once a future has completed (returned Ready from poll), calling its poll method again may panic, block forever, or cause other kinds of problems; the Future trait places no requirements on the effects of such a call. However, as the poll method is not marked unsafe, Rust’s usual rules apply: calls must never cause undefined behavior (memory corruption, incorrect use of unsafe functions, or the like), regardless of the future’s state.
I could imagine a (future) compiler option which (for example) just causes the program to halt (or panic without a message, which might be nicer) if such a completed async fn future is polled again.