# Sealed Classes == Rust Enums

**URL:** <https://discuss.kotlinlang.org/t/sealed-classes-rust-enums/2461>\
**Category:** Uncategorized\
**Created:** [April 2, 2017, 3:02am UTC](https://discuss.kotlinlang.org/t/sealed-classes-rust-enums/2461 "2017-04-02T03:02:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thecodewarrior](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/thecodewarrior/32/2239_2.png) [@thecodewarrior](https://discuss.kotlinlang.org/u/thecodewarrior)\
**Post date:** [April 2, 2017, 3:02am UTC](https://discuss.kotlinlang.org/t/sealed-classes-rust-enums/2461/1 "2017-04-02T03:02:49Z")

</div>

I was just sitting over here writing up a proposal to add Rust-like Enums to kotlin, when I had to look up what `switch` was called in kotlin, cause I knew it was different. I saw the sealed classes entry on the website and thought “I never did look into those…” Well lo and behold, they are almost exactly Rust enums!

The enums and pattern matching were the one thing I missed from Rust, and as it turns out, Kotlin has _everything_.

---

<div class="post-metadata">

**Author:** ![chimmihc](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/chimmihc/32/2013_2.png) [@chimmihc](https://discuss.kotlinlang.org/u/chimmihc)\
**Post date:** [April 3, 2017, 12:04am UTC](https://discuss.kotlinlang.org/t/sealed-classes-rust-enums/2461/2 "2017-04-03T00:04:50Z")

</div>

Kotlin has pattern matching?

---

<div class="post-metadata">

**Author:** ![thecodewarrior](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/thecodewarrior/32/2239_2.png) [@thecodewarrior](https://discuss.kotlinlang.org/u/thecodewarrior)\
**Post date:** [April 8, 2017, 7:36am UTC](https://discuss.kotlinlang.org/t/sealed-classes-rust-enums/2461/3 "2017-04-08T07:36:59Z")

</div>

No, but it does smart casting meaning you can just use the variable.

```
var enumVar = Status.Processing("somedata")
when(enumVar) {
    is Status.Loading -> {
        enumVar.someLoadingProp
    }
    is Status.Processing -> {
        enumVar.theData
    }
}

```
