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( .push(Language::all().iter().cloned().fold(
Column::new().padding(10).spacing(20), Column::new().padding(10).spacing(20),
|choices, language| { |choices, language| {
let label: &str = language.into();
choices.push(Radio::new( choices.push(Radio::new(
language, language,
label, language,
selection, selection,
StepMessage::LanguageSelected, StepMessage::LanguageSelected,
)) ))
@ -730,16 +729,16 @@ impl Language {
} }
} }
impl From<Language> for &str { impl From<Language> for String {
fn from(language: Language) -> &'static str { fn from(language: Language) -> String {
match language { String::from(match language {
Language::Rust => "Rust", Language::Rust => "Rust",
Language::Elm => "Elm", Language::Elm => "Elm",
Language::Ruby => "Ruby", Language::Ruby => "Ruby",
Language::Haskell => "Haskell", Language::Haskell => "Haskell",
Language::C => "C", Language::C => "C",
Language::Other => "Other", Language::Other => "Other",
} })
} }
} }