Merge pull request #260 from 0x7CFE/fix-checkbox-label
Checkbox label is now `Into<String>`
This commit is contained in:
commit
0f60253661
@ -530,7 +530,7 @@ impl<'a> Step {
|
||||
|choices, language| {
|
||||
choices.push(Radio::new(
|
||||
language,
|
||||
language.into(),
|
||||
language,
|
||||
selection,
|
||||
StepMessage::LanguageSelected,
|
||||
))
|
||||
@ -729,16 +729,16 @@ impl Language {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Language> for &str {
|
||||
fn from(language: Language) -> &'static str {
|
||||
match language {
|
||||
impl From<Language> for String {
|
||||
fn from(language: Language) -> String {
|
||||
String::from(match language {
|
||||
Language::Rust => "Rust",
|
||||
Language::Elm => "Elm",
|
||||
Language::Ruby => "Ruby",
|
||||
Language::Haskell => "Haskell",
|
||||
Language::C => "C",
|
||||
Language::Other => "Other",
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,14 @@ impl<Message, Renderer: self::Renderer + text::Renderer>
|
||||
/// `Message`.
|
||||
///
|
||||
/// [`Checkbox`]: struct.Checkbox.html
|
||||
pub fn new<F>(is_checked: bool, label: &str, f: F) -> Self
|
||||
pub fn new<F>(is_checked: bool, label: impl Into<String>, f: F) -> Self
|
||||
where
|
||||
F: 'static + Fn(bool) -> Message,
|
||||
{
|
||||
Checkbox {
|
||||
is_checked,
|
||||
on_toggle: Box::new(f),
|
||||
label: String::from(label),
|
||||
label: label.into(),
|
||||
width: Length::Shrink,
|
||||
size: <Renderer as self::Renderer>::DEFAULT_SIZE,
|
||||
spacing: Renderer::DEFAULT_SPACING,
|
||||
|
@ -53,7 +53,12 @@ impl<Message, Renderer: self::Renderer> Radio<Message, Renderer> {
|
||||
/// receives the value of the radio and must produce a `Message`.
|
||||
///
|
||||
/// [`Radio`]: struct.Radio.html
|
||||
pub fn new<F, V>(value: V, label: &str, selected: Option<V>, f: F) -> Self
|
||||
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,
|
||||
@ -61,7 +66,7 @@ impl<Message, Renderer: self::Renderer> Radio<Message, Renderer> {
|
||||
Radio {
|
||||
is_selected: Some(value) == selected,
|
||||
on_click: f(value),
|
||||
label: String::from(label),
|
||||
label: label.into(),
|
||||
style: Renderer::Style::default(),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user