From f508cd91941e73366bc6268dc136ec5b326b1474 Mon Sep 17 00:00:00 2001 From: Lucas Colombo Date: Fri, 20 Sep 2024 21:38:53 -0300 Subject: [PATCH] =?UTF-8?q?feat(cli):=20=E2=9C=A8=20gridselector:=20GridIt?= =?UTF-8?q?em=20to=20String?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cli/tui/widgets/gridselector/state.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/cli/tui/widgets/gridselector/state.rs b/lib/cli/tui/widgets/gridselector/state.rs index 72f99af..85cc64b 100644 --- a/lib/cli/tui/widgets/gridselector/state.rs +++ b/lib/cli/tui/widgets/gridselector/state.rs @@ -12,10 +12,6 @@ use ratatui::text::Text; pub struct GridItem(String); impl GridItem { - // pub fn new(value: String) -> Self { - // Label(value) - // } - // accept both String and &str pub fn new(value: S) -> Self where @@ -25,13 +21,20 @@ impl GridItem { } } -// implement a way to convert Label into &str +// convert Label into &str impl AsRef for GridItem { fn as_ref(&self) -> &str { &self.0 } } +// convert Label into String +impl Into for GridItem { + fn into(self) -> String { + self.0.clone() + } +} + // Specify the lifetime for the implementation impl<'a> From for Text<'a> { fn from(val: GridItem) -> Self {