Sisu
E0098

Value that cannot be interpolated

Error

Built from the repository at commit a8614dc.

An interpolation writes an i64, a u8, an f64, a bool, a char or a string as text, as print does. An array, an optional, an object of a class or a unit value has no one text, so interpolating it is an error at the interpolated expression.

Why

There is no one way to write an array as text: with or without brackets, separators or spaces. An optional may be None, which the program must decide how to show. Build the text the program needs: an array's in a for loop, an optional's after unwrapping it with if let, or with a default through ??.

Broken

fn main() {
    let xs = [1, 2, 3]
    print("{xs}")
}

What sisu says

error[E0098]: cannot interpolate `[i64]`
 --> E0098.sisu:3:13
  |
3 |     print("{xs}")
  |             ^^
  |
  = help: build the text in a `for` loop

sisu: 1 error
sisu: for more on a code, run `sisu explain <code>`: E0098

Fixed

fn main() {
    let xs = [1, 2, 3]
    let mut text = ""
    for x in xs {
        text += "{x} "
    }
    print(text)
}

Related

  • E0060: print or eprint of an array.