Function that is annotated with
#[must_use]
returns ()
45 Self { cells }
46 }
47
48 #[must_use] 49 pub fn update_state(&mut self, player: Player, position: usize) { 50 let position = position - 1; 51 let (x, y) = (position / 3, position % 3); 52 self.cells[x][y] = player; 53 } 54
55 pub fn get_state(&self, position: usize) -> Player {
56 let position = position - 1;
Description
The must_use
attribute is used to issue a diagnostic warning when a value is
not "used". However, when a function without a return value is annotated with
this attribute, the warning raised is useless because unit values are useless.
The attribute is likely a remnant of a refactoring that removed the return
type.
Remove the #[must_use]
attribute from this function.
Bad practice
#[must_use]
fn returns_nothing() { /* ... */ }
#[must_use]
fn returns_unit() -> () { /* ... */ }
Recommended
fn returns_nothing() { /* ... */ }
fn returns_unit() -> () { /* ... */ }