menu

needless-pass-by-value

Disallow passing parameters by value when they are never consumed or mutated

Taking ownership of a move-only parameter prevents callers from retaining it when the body only reads the value. Instead, you SHOULD accept a readonly borrow when the function neither mutates nor consumes the parameter. Keep ownership when transferring the value is part of the callable's behavior.

Reported

1struct Packet {2    code: int32;3}4 5function packetCode(packet: Packet): int32 {6    return packet.code;7}

Accepted

1struct Packet {2    code: int32;3}4 5function packetCode(packet: &readonly Packet): int32 {6    return packet.code;7}