Lyricdev
GitHub

LYR-SEM0054

a static member declared 'mut'

error ยท spec 03-types

A member function is declared both static and mut.

Explanation

mut on a method says that it may change its receiver. A static function has no receiver, so the word has nothing to speak about.

Drop mut, or drop static if the function is meant to work on a value of the type.

Wrong

struct Counter {
    n: int,
    static mut fn reset(): void {}
}

fn main(): void {
    Counter.reset();
}
struct Counter {
    n: int,
    static fn reset(): void {}
}

fn main(): void {
    Counter.reset();
}