I have a struct:
pub struct Test {
pub x: i32,
pub y: i32,
}
I'd like to have a function that mutates this — easy:
pub fn mutateit(&mut self) {
self.x += 1;
}
This makes the entire struct mutable for the duration of the function call of mutateit
, correct? I only want to mutate x
, and I don't want to mutate y
. Is there any way to just mutably borrow x
?