compiler-explorer / compiler-explorer/compiler-explorer

[REQUEST]: Supporting `enum_dispatch` in Rust

Open
#7,845 0 comments 0 reactions 0 assignees View on GitHub
lang-rust request
Dominant language
TypeScript
Stars
19.1k
Forks
2.1k
Avg merge
3d 15h
Merged PRs (30d)
67

Description

### Is your feature request related to a problem? Please describe

I'd like to be able to use [`enum_dispatch`](https://docs.rs/enum_dispatch/latest/enum_dispatch/) with Rust. The motivation is to compare it (sample [here](https://godbolt.org/z/GzjaxWvEs)) with C++ compile-time dispatch using `std::variant` and `std::visit` (sample [here](https://godbolt.org/z/44b7jcE9r))

### Describe the solution you'd like

Being able to use

```rust
extern crate enum_dispatch;

use enum_dispatch::enum_dispatch;
```

### Describe alternatives you've considered

None, as `enum_dispatch` isn't present in the [available Rust crates](https://conan.compiler-explorer.com/libraries_rust.html)

### Additional context

Not applicable

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.