Clone instead of Copy on Radio's value? #862
Answered
by
hecrj
itytophile
asked this question in
Q&A
-
Hi, I'd like my Radio button to use a String as its value but it only accepts types that implement Copy: pub fn new<F, V>(
value: V,
label: impl Into<String>,
selected: Option<V>,
f: F
) -> Self where
V: Eq + Copy,
F: 'static + Fn(V) -> Message, Is there a particular reason for this design? |
Beta Was this translation helpful? Give feedback.
Answered by
hecrj
May 4, 2021
Replies: 1 comment 1 reply
-
The main reason is that I believe it's better to rely on Besides being cheaper, it should also be easier to pattern match when you get a |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hecrj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The main reason is that I believe it's better to rely on
enum
values for these kinds of widgets, instead of using strings both for the value and the label.Besides being cheaper, it should also be easier to pattern match when you get a
Message
with the selected value.