Use SharedString for Labels

This commit is contained in:
Marshall Bowers 2023-10-18 10:58:50 -04:00
parent 8321b9430e
commit 2b53c67789
2 changed files with 4 additions and 7 deletions

View file

@ -48,7 +48,7 @@ pub enum LabelSize {
#[derive(Element, Clone)] #[derive(Element, Clone)]
pub struct Label<S: 'static + Send + Sync + Clone> { pub struct Label<S: 'static + Send + Sync + Clone> {
state_type: PhantomData<S>, state_type: PhantomData<S>,
label: String, label: SharedString,
color: LabelColor, color: LabelColor,
size: LabelSize, size: LabelSize,
highlight_indices: Vec<usize>, highlight_indices: Vec<usize>,
@ -56,10 +56,7 @@ pub struct Label<S: 'static + Send + Sync + Clone> {
} }
impl<S: 'static + Send + Sync + Clone> Label<S> { impl<S: 'static + Send + Sync + Clone> Label<S> {
pub fn new<L>(label: L) -> Self pub fn new(label: impl Into<SharedString>) -> Self {
where
L: Into<String>,
{
Self { Self {
state_type: PhantomData, state_type: PhantomData,
label: label.into(), label: label.into(),

View file

@ -1,6 +1,6 @@
pub use gpui3::{ pub use gpui3::{
div, Click, Element, Hover, IntoAnyElement, ParentElement, ScrollState, Styled, ViewContext, div, Click, Element, Hover, IntoAnyElement, ParentElement, ScrollState, SharedString, Styled,
WindowContext, ViewContext, WindowContext,
}; };
pub use crate::{theme, ButtonVariant, ElementExt, Theme}; pub use crate::{theme, ButtonVariant, ElementExt, Theme};