[Mesa-dev] Rust drivers in Mesa

Jacob Lifshay programmerjake at gmail.com
Fri Oct 2 18:12:18 UTC 2020

On Fri, Oct 2, 2020, 10:53 Jason Ekstrand <jason at jlekstrand.net> wrote:

>  2. Rust's enums look awesome but are only mostly awesome:
>     a. Pattern matching on them can lead to some pretty deep
> indentation which is a bit annoying.
>     b. There's no good way to have multiple cases handled by the same
> code like you can with a C switch; you have to either repeat it or
> break it out into a generic helper.

You can use | in match which could help with 2.b:
match make_my_enum() {
    B { strv: s, .. } | C(MyStruct(s)) => println!("B or C: the string is
{}", s),
    A(_) => {}
struct MyStruct(String);
enum MyEnum {
    B {
        intv: i32,
        strv: String,

Jacob Lifshay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20201002/de3b62a4/attachment-0001.htm>

More information about the mesa-dev mailing list