diff --git a/crates/docs_preprocessor/src/main.rs b/crates/docs_preprocessor/src/main.rs index c8e945c7e83564d162e0b939b92169b905558393..8eeeb6f0c5a105e186bdeac3e83807e50db721ea 100644 --- a/crates/docs_preprocessor/src/main.rs +++ b/crates/docs_preprocessor/src/main.rs @@ -243,7 +243,6 @@ struct ActionDef { fn dump_all_gpui_actions() -> Vec { let mut actions = gpui::generate_list_of_all_registered_actions() - .into_iter() .map(|action| ActionDef { name: action.name, human_name: command_palette::humanize_action_name(action.name), diff --git a/crates/gpui/src/action.rs b/crates/gpui/src/action.rs index e099bfec28c3e3f15267348694f60c961df6f086..b179076cd5f0da826ca0d5da5e2a5a41cbb5e806 100644 --- a/crates/gpui/src/action.rs +++ b/crates/gpui/src/action.rs @@ -403,12 +403,10 @@ impl ActionRegistry { /// Useful for transforming the list of available actions into a /// format suited for static analysis such as in validating keymaps, or /// generating documentation. -pub fn generate_list_of_all_registered_actions() -> Vec { - let mut actions = Vec::new(); - for builder in inventory::iter:: { - actions.push(builder.0()); - } - actions +pub fn generate_list_of_all_registered_actions() -> impl Iterator { + inventory::iter:: + .into_iter() + .map(|builder| builder.0()) } mod no_action { diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 6cecfcc0e42b239dc98db9391650f0618530d52c..957c7c4be6e2b818c9a750f5b0e0037a29607eda 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1250,11 +1250,7 @@ impl App { .downcast::() .unwrap() .update(cx, |entity_state, cx| { - if let Some(window) = window { - on_new(entity_state, Some(window), cx); - } else { - on_new(entity_state, None, cx); - } + on_new(entity_state, window.as_deref_mut(), cx) }) }, ), diff --git a/crates/gpui/src/color.rs b/crates/gpui/src/color.rs index 7fc9c24393907d3991edcf9ae82b25eee419e766..a16c8f46bef28300deaeb4a603beabb1045f6b14 100644 --- a/crates/gpui/src/color.rs +++ b/crates/gpui/src/color.rs @@ -12,18 +12,13 @@ use std::{ /// Convert an RGB hex color code number to a color type pub fn rgb(hex: u32) -> Rgba { - let r = ((hex >> 16) & 0xFF) as f32 / 255.0; - let g = ((hex >> 8) & 0xFF) as f32 / 255.0; - let b = (hex & 0xFF) as f32 / 255.0; + let [_, r, g, b] = hex.to_be_bytes().map(|b| (b as f32) / 255.0); Rgba { r, g, b, a: 1.0 } } /// Convert an RGBA hex color code number to [`Rgba`] pub fn rgba(hex: u32) -> Rgba { - let r = ((hex >> 24) & 0xFF) as f32 / 255.0; - let g = ((hex >> 16) & 0xFF) as f32 / 255.0; - let b = ((hex >> 8) & 0xFF) as f32 / 255.0; - let a = (hex & 0xFF) as f32 / 255.0; + let [r, g, b, a] = hex.to_be_bytes().map(|b| (b as f32) / 255.0); Rgba { r, g, b, a } } @@ -63,14 +58,14 @@ impl Rgba { if other.a >= 1.0 { other } else if other.a <= 0.0 { - return *self; + *self } else { - return Rgba { + Rgba { r: (self.r * (1.0 - other.a)) + (other.r * other.a), g: (self.g * (1.0 - other.a)) + (other.g * other.a), b: (self.b * (1.0 - other.a)) + (other.b * other.a), a: self.a, - }; + } } } } @@ -494,12 +489,12 @@ impl Hsla { if alpha >= 1.0 { other } else if alpha <= 0.0 { - return self; + self } else { let converted_self = Rgba::from(self); let converted_other = Rgba::from(other); let blended_rgb = converted_self.blend(converted_other); - return Hsla::from(blended_rgb); + Hsla::from(blended_rgb) } } diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 59f432faafbef0c607dd75d8f4623cc2be7b959a..6309c3a1373b2ce30db1f7eac0d1449f52ed4f7d 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -1391,7 +1391,6 @@ fn dump_all_gpui_actions() { documentation: Option<&'static str>, } let mut actions = gpui::generate_list_of_all_registered_actions() - .into_iter() .map(|action| ActionDef { name: action.name, human_name: command_palette::humanize_action_name(action.name),