Closed
Description
In trying to choose whether to use #[inline]
on a function, I found the section in this book. However, here are several questions I had after reading it:
- Does
#[inline]
apply to all implementations of a function defined by a trait, if the trait's declaration of that function is annotated? - Does
#[inline]
apply to an implementation of a trait function if the trait's declaration does not have an#[inline]
annotation? - Will rustc ever inline a function from another crate without
#[inline]
? - Will rustc inline a function from another crate if it is annotated with
#[inline]
? - In what types of situations would incorrectly using this annotation cause programs to be slower? What makes those uses of inline slower? I'm guessing it's related to keeping the instruction size small and cache-friendly, but I don't know for sure.
I volunteer to write the answers to these questions in polished form for the book and submit a pull request if someone can answer the substance of them here.