Skip to content

Commit

Permalink
Simplify Language conversion in tour
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Apr 6, 2020
1 parent 1a9bfd9 commit 3c47e3e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions examples/tour/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
))
Expand Down Expand Up @@ -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",
}
})
}
}

Expand Down

0 comments on commit 3c47e3e

Please sign in to comment.