From edab58e91a98ad160e4f6315ef054ae79685ff8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Tue, 29 Sep 2026 19:16:41 -0400 Subject: [PATCH] =?UTF-8?q?T44d=20Web=20=C2=B7=20The=20gallery's=20start?= =?UTF-8?q?=20takes=20its=20defaults=20from=20one=20place?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/gallery/main.rs | 9 ++------- examples/gallery/shell.rs | 3 ++- examples/gallery/web.rs | 18 ++++++------------ 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/examples/gallery/main.rs b/examples/gallery/main.rs index f9995eb..2ca4940 100644 --- a/examples/gallery/main.rs +++ b/examples/gallery/main.rs @@ -96,6 +96,7 @@ fn choose(window: WindowHandle, choice: shell::Choice, cx: &mut } /// What the gallery opens on. +#[derive(Default)] pub struct Start { pub page: usize, /// One section, by title or slug, drawn alone. @@ -154,13 +155,7 @@ struct Args { #[cfg(not(target_family = "wasm"))] fn parse_args() -> Result { let mut args = Args { - start: Start { - page: 0, - story: None, - choice: shell::Choice::Light, - narrow: None, - failure: None, - }, + start: Start::default(), page: None, capture: None, }; diff --git a/examples/gallery/shell.rs b/examples/gallery/shell.rs index 0df1375..644b452 100644 --- a/examples/gallery/shell.rs +++ b/examples/gallery/shell.rs @@ -13,8 +13,9 @@ use gpui::{ use crate::{Start, pages, ui::Story}; -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Default)] pub enum Choice { + #[default] Light, Dark, System, diff --git a/examples/gallery/web.rs b/examples/gallery/web.rs index 0d890be..47998cb 100644 --- a/examples/gallery/web.rs +++ b/examples/gallery/web.rs @@ -7,7 +7,10 @@ use gpui_web::{CanvasFontFallback, WebBackendPreference, WebPlatform}; use wasm_bindgen::prelude::*; use web_sys::UrlSearchParams; -use crate::{Start, choose, launch, pages, shell::Choice, shell::Gallery}; +use crate::{ + Start, choose, launch, pages, + shell::{Choice, Gallery}, +}; /// The i18n page's Hebrew: gpui_web asks the browser for emoji and CJK alone. const HEBREW: &[u8] = include_bytes!("fonts/NotoSansHebrew-Regular.ttf"); @@ -36,13 +39,7 @@ fn read(search: &str) -> Result { { bail!("ELY_GALLERY_ASSETS is an address ending in /, not {assets}"); } - let mut start = Start { - page: 0, - story: None, - choice: Choice::Light, - narrow: None, - failure: None, - }; + let mut start = Start::default(); let params = UrlSearchParams::new_with_str(search).map_err(js)?; for key in js_sys::try_iter(¶ms.keys()) .map_err(js)? @@ -80,11 +77,8 @@ pub fn start() { let start = read(&search).unwrap_or_else(|error| { log::error!("gallery: {search} -> {error:#}"); Start { - page: 0, - story: None, - choice: Choice::Light, - narrow: None, failure: Some(SharedString::from(format!("{search}: {error:#}"))), + ..Start::default() } }); // One thread: a static site sends no cross-origin isolation, so there is no shared memory.