Maybe I'm too harsh but this is like nails on chalkboard: https://ratatui.rs/tutorials/json-editor/app/#the-full-application-state. Since it's a beginner tutorial maybe it's driven by the (IMHO misguided) notion that beginners would be confused by using enum fields properly to make invalid states unrepresentable.
App.rs

Ratatui

Here's my WIP for rewriting it into something more reasonable. Which also taught me that an even worse sin of that official front-page tutorial example is that it uses a bunch of overly verbose ways to do things that can be done now in a fraction of the code with their newer helpers.

All in all, it's reduced from the original 371 lines to the current 155 lines. The hierarchical state machine structure is front and center.

https://gist.github.com/pervognsen/1cae9c0f27b7568cc4008c13a1038968

WIP cleaned up version of ratatui.rs JSON editor tutorial example

WIP cleaned up version of ratatui.rs JSON editor tutorial example - json_editor.rs

Gist
@pervognsen i’m not sure about this small app, but considering the points made in https://eighty-twenty.org/2024/07/21/ui-for-sums-remembers-products enums with fields are not the most suitable for ui state.
UI for sums must remember products (eighty-twenty news)

@annanannanse Yeah, I mean, you have to apply case by case design sense and reasoning. For example, my Edit type stores both a key and value String (i.e. String * String) even though in the linear path through the current edit flow (edit key -> edit value -> commit) you don't have a value yet in the 'edit key' step. It was partly for the reason mentioned in the article, and partly because it made the code simpler to do it this way even with the current linear edit flow.

@annanannanse In that example, another option would be

enum Edit {
Key { key: String },
Value { key: String, value: String },
}

but that leads to clumsier, less uniform code and has the sort of issues mentioned in your link.

@pervognsen yeah, it requires some taste and i'm not sure what is suitable for this example or a beginners tutorial. certainly anyone reaching for ratatui wouldn't have any issue with enums with fields at least.