From f2cbc1665597452edb205b5b79b309853fc7e994 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 24 Nov 2025 14:38:43 +0800 Subject: [PATCH] chore: Update to use Rust edition 2024. (#1669) --- Cargo.toml | 4 +++ crates/assets/Cargo.toml | 4 +-- crates/macros/Cargo.toml | 4 +-- crates/reqwest_client/Cargo.toml | 4 +-- crates/story/Cargo.toml | 4 +-- crates/ui/Cargo.toml | 4 +-- crates/ui/src/color_picker.rs | 17 +++++----- crates/ui/src/dock/tab_panel.rs | 13 ++++---- crates/ui/src/dock/tiles.rs | 16 ++++----- crates/ui/src/input/popovers/mod.rs | 8 ++--- crates/ui/src/menu/popup_menu.rs | 16 ++++----- crates/ui/src/root.rs | 21 ++++++++---- crates/ui/src/setting/item.rs | 11 ++++--- crates/ui/src/table/state.rs | 22 ++++++------- crates/ui/src/text/format/html.rs | 6 ++-- crates/ui/src/text/format/html5minify/mod.rs | 34 +++++++++++--------- crates/ui/src/text/node.rs | 31 ++++++++---------- crates/ui/src/time/calendar.rs | 24 ++++++-------- examples/app_assets/Cargo.toml | 4 +-- examples/dialog_overlay/Cargo.toml | 4 +-- examples/hello_world/Cargo.toml | 4 +-- examples/input/Cargo.toml | 2 +- examples/window_title/Cargo.toml | 4 +-- 23 files changed, 133 insertions(+), 128 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ce5e5dae..15e87cc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,10 @@ members = [ ] resolver = "2" +[workspace.package] +publish = false +edition = "2024" + [workspace.dependencies] gpui-component = { path = "crates/ui", version = "0.4.1" } gpui-component-macros = { path = "crates/macros", version = "0.4.1" } diff --git a/crates/assets/Cargo.toml b/crates/assets/Cargo.toml index c97de2d7..9d9cfe23 100644 --- a/crates/assets/Cargo.toml +++ b/crates/assets/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "gpui-component-assets" description = "Default bundled assets for GPUI Component." -edition = "2021" keywords = ["desktop", "gpui", "shadcn", "ui", "uikit"] license = "Apache-2.0" documentation = "https://docs.rs/gpui-component" homepage = "https://longbridge.github.io/gpui-component" repository = "https://github.com/longbridge/gpui-component" -publish = true readme = "README.md" +edition.workspace = true +publish = true version = "0.4.1" [lib] diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index b4e3af0a..dd326626 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -1,10 +1,10 @@ [package] -edition = "2021" name = "gpui-component-macros" description = "Macros for GPUI Component." version = "0.4.1" -publish = true license = "Apache-2.0" +publish = true +edition.workspace = true [lib] proc-macro = true diff --git a/crates/reqwest_client/Cargo.toml b/crates/reqwest_client/Cargo.toml index 14a80bfb..c55831ac 100644 --- a/crates/reqwest_client/Cargo.toml +++ b/crates/reqwest_client/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "reqwest_client" version = "0.4.1" -publish = false license = "Apache-2.0" -edition = "2024" +publish = false +edition.workspace = true [lints] workspace = true diff --git a/crates/story/Cargo.toml b/crates/story/Cargo.toml index 603902d4..80fa33da 100644 --- a/crates/story/Cargo.toml +++ b/crates/story/Cargo.toml @@ -1,8 +1,8 @@ [package] -edition = "2024" name = "gpui-component-story" -publish = false version = "0.4.1" +publish = false +edition.workspace = true [features] inspector = ["gpui-component/inspector"] diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index 28103436..99a1528f 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -1,15 +1,15 @@ [package] description = "UI components for building fantastic desktop application by using GPUI." -edition = "2021" keywords = ["desktop", "gpui", "shadcn", "ui", "uikit"] license = "Apache-2.0" name = "gpui-component" documentation = "https://docs.rs/gpui-component" homepage = "https://longbridge.github.io/gpui-component" repository = "https://github.com/longbridge/gpui-component" -publish = true readme = "../../README.md" version = "0.4.1" +publish = true +edition.workspace = true [lib] doctest = false diff --git a/crates/ui/src/color_picker.rs b/crates/ui/src/color_picker.rs index 9634dbb4..a3383976 100644 --- a/crates/ui/src/color_picker.rs +++ b/crates/ui/src/color_picker.rs @@ -1,20 +1,21 @@ use gpui::{ - anchored, canvas, deferred, div, prelude::FluentBuilder as _, px, relative, App, AppContext, - Bounds, ClickEvent, Context, Corner, ElementId, Entity, EventEmitter, FocusHandle, Focusable, - Hsla, InteractiveElement as _, IntoElement, KeyBinding, MouseButton, ParentElement, Pixels, - Point, Render, RenderOnce, SharedString, StatefulInteractiveElement as _, StyleRefinement, - Styled, Subscription, Window, + App, AppContext, Bounds, ClickEvent, Context, Corner, Div, ElementId, Entity, EventEmitter, + FocusHandle, Focusable, Hsla, InteractiveElement as _, IntoElement, KeyBinding, MouseButton, + ParentElement, Pixels, Point, Render, RenderOnce, SharedString, Stateful, + StatefulInteractiveElement as _, StyleRefinement, Styled, Subscription, Window, anchored, + canvas, deferred, div, prelude::FluentBuilder as _, px, relative, }; use crate::{ + ActiveTheme as _, Colorize as _, FocusableExt as _, Icon, Selectable as _, Sizable, Size, + StyleSized, StyledExt, actions::{Cancel, Confirm}, button::{Button, ButtonVariants}, divider::Divider, h_flex, input::{Input, InputEvent, InputState}, tooltip::Tooltip, - v_flex, ActiveTheme as _, Colorize as _, FocusableExt as _, Icon, Selectable as _, Sizable, - Size, StyleSized, StyledExt, + v_flex, }; const CONTEXT: &'static str = "ColorPicker"; @@ -250,7 +251,7 @@ impl ColorPicker { clickable: bool, window: &mut Window, _: &mut App, - ) -> impl IntoElement { + ) -> Stateful
{ let state = self.state.clone(); div() .id(SharedString::from(format!("color-{}", color.to_hex()))) diff --git a/crates/ui/src/dock/tab_panel.rs b/crates/ui/src/dock/tab_panel.rs index 1a292858..f766d36e 100644 --- a/crates/ui/src/dock/tab_panel.rs +++ b/crates/ui/src/dock/tab_panel.rs @@ -1,20 +1,21 @@ use std::sync::Arc; use gpui::{ - div, prelude::FluentBuilder, px, relative, rems, App, AppContext, Context, Corner, - DismissEvent, Div, DragMoveEvent, Empty, Entity, EventEmitter, FocusHandle, Focusable, - InteractiveElement as _, IntoElement, ParentElement, Pixels, Render, ScrollHandle, - SharedString, StatefulInteractiveElement, StyleRefinement, Styled, WeakEntity, Window, + App, AppContext, Context, Corner, DismissEvent, Div, DragMoveEvent, Empty, Entity, + EventEmitter, FocusHandle, Focusable, InteractiveElement as _, IntoElement, ParentElement, + Pixels, Render, ScrollHandle, SharedString, StatefulInteractiveElement, StyleRefinement, + Styled, WeakEntity, Window, div, prelude::FluentBuilder, px, relative, rems, }; use rust_i18n::t; use crate::{ + ActiveTheme, AxisExt, IconName, Placement, Selectable, Sizable, button::{Button, ButtonVariants as _}, dock::PanelInfo, h_flex, menu::{DropdownMenu, PopupMenu}, tab::{Tab, TabBar}, - v_flex, ActiveTheme, AxisExt, IconName, Placement, Selectable, Sizable, + v_flex, }; use super::{ @@ -508,7 +509,7 @@ impl TabPanel { placement: DockPlacement, _: &mut Window, cx: &mut Context, - ) -> Option { + ) -> Option", "

Some text

", false, false), + ( + "

Some text

", + "

Some text

", + false, + false, + ), ] { - let mut w = vec![]; - let mut minifier = Minifier::new(&mut w); - minifier - .omit_doctype(true) - .collapse_whitespace(collapse_whitespace) - .preserve_comments(preserve_comments); - minifier.minify(&mut input.as_bytes()).unwrap(); + let mut w = vec![]; + let mut minifier = Minifier::new(&mut w); + minifier + .omit_doctype(true) + .collapse_whitespace(collapse_whitespace) + .preserve_comments(preserve_comments); + minifier.minify(&mut input.as_bytes()).unwrap(); - let s = str::from_utf8(&w).unwrap(); + let s = str::from_utf8(&w).unwrap(); - assert_eq!(expected, s); - } + assert_eq!(expected, s); + } } } diff --git a/crates/ui/src/text/node.rs b/crates/ui/src/text/node.rs index b4bd81a2..54882c9e 100644 --- a/crates/ui/src/text/node.rs +++ b/crates/ui/src/text/node.rs @@ -5,23 +5,23 @@ use std::{ }; use gpui::{ - div, img, prelude::FluentBuilder as _, px, relative, rems, AnyElement, App, DefiniteLength, - Div, Element, ElementId, FontStyle, FontWeight, Half, HighlightStyle, InteractiveElement as _, - IntoElement, Length, ListState, ObjectFit, ParentElement, SharedString, SharedUri, - StatefulInteractiveElement, Styled, StyledImage as _, Window, + AnyElement, App, DefiniteLength, Div, Element, ElementId, FontStyle, FontWeight, Half, + HighlightStyle, InteractiveElement as _, IntoElement, Length, ListState, ObjectFit, + ParentElement, SharedString, SharedUri, StatefulInteractiveElement, Styled, StyledImage as _, + Window, div, img, prelude::FluentBuilder as _, px, relative, rems, }; use markdown::mdast; use ropey::Rope; use crate::{ - h_flex, + ActiveTheme as _, Icon, IconName, StyledExt, h_flex, highlighter::{HighlightTheme, SyntaxHighlighter}, text::inline::{Inline, InlineState}, tooltip::Tooltip, - v_flex, ActiveTheme as _, Icon, IconName, StyledExt, + v_flex, }; -use super::{utils::list_item_prefix, TextViewStyle}; +use super::{TextViewStyle, utils::list_item_prefix}; #[allow(unused)] #[derive(Debug, Default, Clone, PartialEq)] @@ -767,11 +767,7 @@ impl Node { children, checked, .. } => { let checkbox = if let Some(checked) = checked { - if *checked { - "[x] " - } else { - "[ ] " - } + if *checked { "[x] " } else { "[ ] " } } else { "" }; @@ -866,7 +862,7 @@ impl Node { node_cx: &NodeContext, window: &mut Window, cx: &mut App, - ) -> impl IntoElement { + ) -> AnyElement { match item { Node::ListItem { children, @@ -899,10 +895,9 @@ impl Node { // merge content into last item. if last_not_list { if let Some(item_item) = items.last_mut() { - item_item.extend(vec![div() - .overflow_hidden() - .child(text) - .into_any_element()]); + item_item.extend(vec![ + div().overflow_hidden().child(text).into_any_element(), + ]); continue; } } @@ -1116,7 +1111,7 @@ impl Node { node_cx: &NodeContext, window: &mut Window, cx: &mut App, - ) -> impl IntoElement { + ) -> AnyElement { let mb = if options.in_list || options.is_last { rems(0.) } else { diff --git a/crates/ui/src/time/calendar.rs b/crates/ui/src/time/calendar.rs index 1d5c01ec..56230f22 100644 --- a/crates/ui/src/time/calendar.rs +++ b/crates/ui/src/time/calendar.rs @@ -2,16 +2,17 @@ use std::{borrow::Cow, rc::Rc}; use chrono::{Datelike, Local, NaiveDate}; use gpui::{ - prelude::FluentBuilder as _, px, relative, App, ClickEvent, Context, ElementId, Empty, Entity, - EventEmitter, FocusHandle, InteractiveElement, IntoElement, ParentElement, Render, RenderOnce, - SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Window, + App, ClickEvent, Context, Div, ElementId, Empty, Entity, EventEmitter, FocusHandle, + InteractiveElement, IntoElement, ParentElement, Render, RenderOnce, SharedString, Stateful, + StatefulInteractiveElement, StyleRefinement, Styled, Window, prelude::FluentBuilder as _, px, + relative, }; use rust_i18n::t; use crate::{ + ActiveTheme, Disableable as _, IconName, Selectable, Sizable, Size, StyledExt as _, button::{Button, ButtonVariants as _}, - h_flex, v_flex, ActiveTheme, Disableable as _, IconName, Selectable, Sizable, Size, - StyledExt as _, + h_flex, v_flex, }; use super::utils::days_in_month; @@ -543,7 +544,7 @@ impl Calendar { offset_month: usize, window: &mut Window, cx: &mut App, - ) -> impl IntoElement { + ) -> Stateful
{ let state = self.state.read(cx); let (_, month) = state.offset_year_month(offset_month); let day = d.day(); @@ -561,7 +562,7 @@ impl Calendar { let date_id: SharedString = format!("{}_{}", date.format("%Y-%m-%d"), offset_month).into(); self.item_button( - date_id, + date_id.clone(), day.to_string(), is_active, is_in_range, @@ -734,7 +735,7 @@ impl Calendar { disabled: bool, _: &mut Window, cx: &mut App, - ) -> impl IntoElement + Styled + StatefulInteractiveElement { + ) -> Stateful
{ h_flex() .id(id.into()) .map(|this| match self.size { @@ -815,12 +816,7 @@ impl Calendar { ) } - fn render_week( - &self, - week: impl Into, - _: &mut Window, - cx: &mut App, - ) -> impl IntoElement { + fn render_week(&self, week: impl Into, _: &mut Window, cx: &mut App) -> Div { h_flex() .map(|this| match self.size { Size::Small => this.size_7().rounded(cx.theme().radius / 2.0), diff --git a/examples/app_assets/Cargo.toml b/examples/app_assets/Cargo.toml index db4131af..3dfe7a30 100644 --- a/examples/app_assets/Cargo.toml +++ b/examples/app_assets/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2021" name = "app_assets" description = "Example to load icons or images from assets folder." -publish = false version = "0.4.1" +publish = false +edition.workspace = true [dependencies] anyhow.workspace = true diff --git a/examples/dialog_overlay/Cargo.toml b/examples/dialog_overlay/Cargo.toml index cbb6c2a3..e994ab53 100644 --- a/examples/dialog_overlay/Cargo.toml +++ b/examples/dialog_overlay/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2021" name = "dialog_overlay" description = "An example of using gpui-component to create a Dialog with overlay." -publish = false version = "0.4.1" +publish = false +edition.workspace = true [dependencies] anyhow.workspace = true diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index 1c5f3393..a434e0f1 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2021" name = "hello_world" description = "A minimal example of application development with GPUI Component." -publish = false version = "0.4.1" +publish = false +edition.workspace = true [dependencies] anyhow.workspace = true diff --git a/examples/input/Cargo.toml b/examples/input/Cargo.toml index 0cfa4834..1ead4d36 100644 --- a/examples/input/Cargo.toml +++ b/examples/input/Cargo.toml @@ -2,7 +2,7 @@ name = "input" version = "0.4.1" publish = false -edition = "2024" +edition.workspace = true [dependencies] anyhow.workspace = true diff --git a/examples/window_title/Cargo.toml b/examples/window_title/Cargo.toml index ac2e45ab..cf491f49 100644 --- a/examples/window_title/Cargo.toml +++ b/examples/window_title/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2021" name = "window_title" description = "An example of using gpui-component to create a window with a custom title bar." -publish = false version = "0.4.1" +publish = false +edition.workspace = true [dependencies] anyhow.workspace = true