this post was submitted on 29 Jun 2024
86 points (93.0% liked)
Programming
17366 readers
165 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
We've been using Leptos at work, which is a similar framework (and probably shares half the stack with Dioxus).
And yeah, it's really good. My favorite thing about using Rust for the UI is algebraic data types.
So, in Rust when you call a function which can fail, there isn't an exception being thrown, but rather you get a
Result
-type as return value.This
Result
can either contain anOk
with the actual return value inside. Or it can contain anErr
with an error message inside.So, in your UI code, you just hand this
Result
all the way to your display code and there you either display the value or you display the error.No more uninitialized variables, no more separate booleans to indicate that the variable is uninitialized, no more unreadable multi-line ternaries.
It just becomes so much simpler to load something from the backend and display it, which is kind of important in frontend code.