feat(cli): gridselector: GridItem to String

This commit is contained in:
Lucas Colombo 2024-09-20 21:38:53 -03:00
parent 00f231d79f
commit f508cd9194
Signed by: lucas
GPG Key ID: EF34786CFEFFAE35

View File

@ -12,10 +12,6 @@ use ratatui::text::Text;
pub struct GridItem(String); pub struct GridItem(String);
impl GridItem { impl GridItem {
// pub fn new(value: String) -> Self {
// Label(value)
// }
// accept both String and &str // accept both String and &str
pub fn new<S>(value: S) -> Self pub fn new<S>(value: S) -> Self
where where
@ -25,13 +21,20 @@ impl GridItem {
} }
} }
// implement a way to convert Label into &str // convert Label into &str
impl AsRef<str> for GridItem { impl AsRef<str> for GridItem {
fn as_ref(&self) -> &str { fn as_ref(&self) -> &str {
&self.0 &self.0
} }
} }
// convert Label into String
impl Into<String> for GridItem {
fn into(self) -> String {
self.0.clone()
}
}
// Specify the lifetime for the implementation // Specify the lifetime for the implementation
impl<'a> From<GridItem> for Text<'a> { impl<'a> From<GridItem> for Text<'a> {
fn from(val: GridItem) -> Self { fn from(val: GridItem) -> Self {