From 3c47e3e2295e2dd6ca60e50111b9b89a4bb025fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 6 Apr 2020 20:12:16 +0200 Subject: [PATCH] Simplify `Language` conversion in `tour` --- examples/tour/src/main.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 0928cf30..c9678b9d 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -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 for &str { - fn from(language: Language) -> &'static str { - match language { +impl From 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", - } + }) } }