I’ve been programming in Rust for over a year now and I love the zero-cost abstractions it provides. Now I would like to get my hands dirty writing my own. While I can come up with and implement the traits, adapters, and wrappers, I can only verify that they do the correct thing. However, I would like to see if they really are zero-cost abstractions. How would I do that? Is looking at the assembly output with
--emit asm the only option?
PS: More specifically, what I’ve created is more or less a bunch of iterators and adapters that transform and aggregate a sequence of values. Now I added an aggregator adapter that collects the output values of its predecessor in a buffer until full, and then produces that buffer as its output. I want to see whether my supposedly zero-cost abstraction chain boils down to a for loop populating that buffer.