error positional-literal
Позиционный литерал здесь недопустим.
What it means#
A positional literal T(e1, e2, ...) is allowed only when all fields are visible, the type is not @sealed, and the type has at most 4 fields without a default value (§4.3). In other cases the call is resolved to T.new(...) if it exists; otherwise it is an error.
Example#
data Order {
id: u64
user: u64
item: u64
qty: u32
price: u64
}
fn main() {
let o = Order(1, 2, 3, 4, 5) // <- positional-literal (5 required fields)
}error
positional-literal
How to fix#
data Order {
id: u64
user: u64
item: u64
qty: u32
price: u64
}
fn main() {
let o = Order{ id: 1, user: 2, item: 3, qty: 4, price: 5 }
}Use a named literal T{ field: value }, or declare init new(...) so that T(args) resolves to it.