Search code examples
rustrust-cargorust-piston

Cannot compile stb_truetype 0.2.4 because "slice pattern syntax is experimental"


I was following a tutorial on how to setup the piston library, but when I tried to compile it I got the following error message:

error[E0658]: slice pattern syntax is experimental (see issue #23121)
   --> /home/alexander/.cargo/registry/src/github.com-1ecc6299db9ec823/stb_truetype-0.2.4/src/lib.rs:606:13
    |
606 |         let [g1, g2] = if self.index_to_loc_format == 0 {
    |             ^^^^^^^^

I am using the same versions of all the libraries and the same code, what did I do wrong?


Solution

  • Slices patterns have been stabilized in rustc 1.26.0 (2018-05-10).

    On older compilers, they were only available experimentally, that is: 1) requiring a nightly compiler, 2) requiring the using crate to explicitly enable them with #![feature(slice_patterns)], which newer versions of piston do not do.

    You will have to update your compiler to use this version of piston.