error sealed-literal
Тип @sealed создаётся только через init.
What it means#
@sealed forbids literals outside the impl of the type; values are built only by init constructors (§4.3). This lets the type guarantee its invariants.
Example#
@sealed data Account {
id: u64
balance: i64
}
impl Account {
init new(id: u64) -> Self => Self{ id, balance: 0 }
}
fn main() io {
let a = Account{ id: 1, balance: 100 } // <- sealed-literal
print("{a.balance}")
}error
sealed-literal
How to fix#
@sealed data Account {
id: u64
balance: i64
}
impl Account {
init new(id: u64) -> Self => Self{ id, balance: 0 }
}
fn main() io {
let a = Account.new(1)
print("{a.balance}")
}Call one of the init constructors (Account.new(1)) or add a constructor that fits your need.