error not-overloadable
What it means#
Overloading with op is possible for arithmetic, bitwise, comparison (through <=>), [], (), as and compound assignment operators. These cannot be overloaded: && || ?? ?. ? ! is = -> ?-> ~> !> |> =>, . and .. (§5.3).
Example#
data Flag { on: bool }
impl Flag {
static op &&(a: Flag, b: Flag) -> Flag => Flag{ on: a.on } // <- not-overloadable
}error
not-overloadable
How to fix#
data Flag { on: bool }
impl Flag {
fn and(other: Flag) -> Flag => Flag{ on: on }
}Use an ordinary method, or declare a new operator with the operator keyword and a free symbol.