E0109
Unsupported format spec
ErrorSisu's format specs take only an alignment (<, > or ^), a width and a precision: {x:>8.2}. The other parts of Rust's and Python's specs are errors: zero padding ({n:03}), a sign ({x:+}), a type such as e or x, a fill character before the alignment ({s:*^9}), a space ({ x:>5 }), and a width or precision taken from a variable ({x:>{w}}). A width cannot start with 0. The error points at the spec, from its :.
Why
A small spec is quick to read and has one meaning. Each part left out has another way to say it, and there is no single rewrite to offer, so there is no fix. Build the text you need with ordinary code, such as a loop that adds "0" for zero padding, or pad to a fixed width.
Broken
fn main() {
let n = 7
print("{n:03}")
}
What sisu says
error[E0109]: Sisu's format specs take only alignment, width and precision --> E0109.sisu:3:14 | 3 | print("{n:03}") | ^^^ sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0109
Fixed
fn main() {
let n = 7
print("{n:3}")
}
Related
- E0108: a format spec that the grammar does not hold.
Sisu