I've noticed that many iterator methods are marked as
#[inline] (eg. https://doc.rust-lang.org/src/core/iter/traits/iterator.rs.html#335), but some are not (eg.
sum, while it only calls into another function as it's only part of the body). Who makes the decision what should and should not be
I'm asking for a specific use case. I'm playing with autovectorization and function multiversioning (using the multiversion crate). The thing is, when a function gets inlined, it inherits the allowed instructions of the parent function, but if it is called as a function, it uses only the basic instruction set even if it is the only place that function is being called.
sum does this to me a lot, that it refuses to get inlined, so I have to unroll the summing manually by a for cycle. Shouldn't the one-line method (and similar ones) be marked inline and leave it up to the
Sum::sum implementation to „decide“ if it wants to be inlined or not?