Simplify Language conversion in tour

This commit is contained in:
Héctor Ramón Jiménez 2020-04-06 20:12:16 +02:00
parent 1a9bfd9e73
commit 3c47e3e229

View File

@ -528,10 +528,9 @@ impl<'a> Step {
.push(Language::all().iter().cloned().fold(
Column::new().padding(10).spacing(20),
|choices, language| {
let label: &str = language.into();
choices.push(Radio::new(
language,
label,
language,
selection,
StepMessage::LanguageSelected,
))
@ -730,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",
}
})
}
}