This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/krabsticks64 on 2024-04-08 03:52:46.


Hello! I was wondering, if I have a method like:

pub fn with_field(mut self, value: u32) -> Self {
    self.field = value;
    self
}

would rust always be able to optimize it? or would it sometimes be copied? (assuming we’re compiling with optimizations, and the type is sufficiently big, such that copying it is non trivial).