Lyricdev
GitHub

LYR-PAR0032

a function without 'fn', or its words out of order

error · spec 03-types

Where a function or method is declared, fn is missing after its other words, or inline static is written where the order is static inline; an extern block declares no function.

Explanation

The words of a function stand in one order: [static] [inline] [mut] fn name(…). inline static is refused and read as what it says; a mut or static without fn declares nothing.

Write fn, and the words in their order.

Wrong

struct Crate {
    value: int,
    inline static fn make(v: int): Crate {
        return Crate { value = v };
    }
}

fn main(): void {
    let _ = Crate.make(4);
}
struct Crate {
    value: int,
    static inline fn make(v: int): Crate {
        return Crate { value = v };
    }
}

fn main(): void {
    let _ = Crate.make(4).value;
}