Convenient way to impl View for MyErrorType
#3657
Replies: 2 comments 3 replies
-
Just going to copy and paste this section of the 0.7 release notes in case it's useful — also happy to discuss specifics in more detail if you want to give more specifics about what you're currently doing/not doing.
|
Beta Was this translation helpful? Give feedback.
-
Ahh, very interesting! |
Beta Was this translation helpful? Give feedback.
-
A very handy pattern I've honed from writing many components in
leptos
is defining a clonable andthiserror::Error
pub enum ComponentError
which I then translate into an error ui.Usually I put this translation layer on a method of the error type. But it would be more convenient if my type natively implemented
leptos::View
. I've only briefly explored this route, but stopped when I saw the methods onRenderHtml
.Is there an existing easy way to do this? It wouldn't be too difficult I imagine if I used type erasure, but it would be nice to do this in a way that the compiler can optimize away as a zero cost abstraction (thinking some blanket trait impls)
Beta Was this translation helpful? Give feedback.
All reactions