3 ms·
If your okay with macros, probably nightly only, then it seems reasonable. There is also slice matching on stable, which let's you match on parts of slices: ht
by swsieber 6y ago
If your okay with macros, probably nightly only, then it seems reasonable.
There is also slice matching on stable, which let's you match on parts of slices: https://github.com/rust-lang/rust/pull/67712/ https://github.com/rust-lang/rust/pull/67712/ . It went out in 1.42. It has some stuff which makes binary stuff easier, but not by much. But perhaps someday you'll get native binary matching in the language that's closer to what Erlang offers.
It made it in the 1.42 release.
- archseer 6y ago^ agree with this, slice_patterns fulfilled my needs on the byte level at least. Bit level you could extract some parts of https://github.com/archseer/enigma/blob/master/enigma/src/bitstring.rs https://github.com/archseer/enigma/blob/master/enigma/src/bi... and wrap them in a macro but it's a bit clunky. I tend to just do it by hand (match a { a if a ^ 0b1100_0000 => ... } etc)