The initial intention was to make the code a little more elegant and match on
the Vec itself instead of its length, however there's also a - probably
minuscule - performance advantage:
`Vec::remove` internally copies the removed element onto the stack. In this case
that's a `StructMember` weighting 48 bytes. The `Binding` we are actually
interested in is only 8 bytes tough.
Cloning just the `Binding` saves us from copying 40 bytes for nothing.
Previously the lexer would accept any alphanumeric character as part of an
identifier. The spec only allowes identifiers to consist of ASCII alphanumeric
characters though.
Until now the WGSL parser would interpret a character index as a byte index.
This could lead to a panic on invalid input strings like "\"\u{2}ПЀ\u{0}\"",
because it would use that index to slice a string without ensuring the slicing
happens on a character boundary.
One possible fix would have been to call `str::find` instead of `position`,
however by relying on `splitn` instead of slicing a str manually it is
easier to convince ourselves that this code can no longer panic.
Fixes https://github.com/gfx-rs/naga/issues/90