error it-outside-chain
it использован вне шага цепочки.
What it means#
The contextual word it denotes the value of the previous step, and exists only inside a step of a chain or pipeline (§8.4, §10.6). In a nested chain it refers to the innermost one; outside, it is an ordinary name and, if undefined, is rejected.
Example#
fn main() io {
let y = it + 1 // <- it-outside-chain
print("{y}")
}error
it-outside-chain
How to fix#
service Users {
@public rpc get(id: u64) -> User
}
data User { name: str }
impl Users {
rpc get(id) { User{ name: "ann" } }
}
fn main() io, net {
let y = await Users.get(1) -> it.name
print("{y}")
}Use it only inside a chain step, or name the value with a lambda (x => ...).