From cca1bf13ce875f5d49e1d63aa6a6bd0b7876bb8b Mon Sep 17 00:00:00 2001 From: Jonathan Spira Date: Mon, 2 Sep 2024 16:46:19 -0400 Subject: [PATCH] added must-use to widgets (#188) added --- crates/yakui-widgets/src/widgets/align.rs | 1 + crates/yakui-widgets/src/widgets/button.rs | 1 + crates/yakui-widgets/src/widgets/canvas.rs | 1 + crates/yakui-widgets/src/widgets/checkbox.rs | 1 + crates/yakui-widgets/src/widgets/circle.rs | 1 + crates/yakui-widgets/src/widgets/colored_box.rs | 1 + crates/yakui-widgets/src/widgets/constrained_box.rs | 1 + crates/yakui-widgets/src/widgets/count_grid.rs | 1 + crates/yakui-widgets/src/widgets/cutout.rs | 1 + crates/yakui-widgets/src/widgets/divider.rs | 1 + crates/yakui-widgets/src/widgets/draggable.rs | 1 + crates/yakui-widgets/src/widgets/flexible.rs | 1 + crates/yakui-widgets/src/widgets/image.rs | 1 + crates/yakui-widgets/src/widgets/layer.rs | 1 + crates/yakui-widgets/src/widgets/list.rs | 1 + crates/yakui-widgets/src/widgets/max_width.rs | 1 + crates/yakui-widgets/src/widgets/nineslice.rs | 1 + crates/yakui-widgets/src/widgets/offset.rs | 1 + crates/yakui-widgets/src/widgets/opaque.rs | 1 + crates/yakui-widgets/src/widgets/pad.rs | 1 + crates/yakui-widgets/src/widgets/panel.rs | 1 + crates/yakui-widgets/src/widgets/reflow.rs | 1 + crates/yakui-widgets/src/widgets/render_text.rs | 1 + crates/yakui-widgets/src/widgets/render_textbox.rs | 1 + crates/yakui-widgets/src/widgets/round_rect.rs | 1 + crates/yakui-widgets/src/widgets/scrollable.rs | 1 + crates/yakui-widgets/src/widgets/slider.rs | 1 + crates/yakui-widgets/src/widgets/spacer.rs | 1 + crates/yakui-widgets/src/widgets/state.rs | 1 + crates/yakui-widgets/src/widgets/text.rs | 1 + crates/yakui-widgets/src/widgets/textbox.rs | 1 + crates/yakui-widgets/src/widgets/unconstrained_box.rs | 1 + crates/yakui-widgets/src/widgets/window.rs | 1 + 33 files changed, 33 insertions(+) diff --git a/crates/yakui-widgets/src/widgets/align.rs b/crates/yakui-widgets/src/widgets/align.rs index cd4b5fbe..c4edec7b 100644 --- a/crates/yakui-widgets/src/widgets/align.rs +++ b/crates/yakui-widgets/src/widgets/align.rs @@ -34,6 +34,7 @@ Align::new(yakui::Alignment::TOP_RIGHT).show(|| { */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Align { pub alignment: Alignment, } diff --git a/crates/yakui-widgets/src/widgets/button.rs b/crates/yakui-widgets/src/widgets/button.rs index 0fe950ed..201aee93 100644 --- a/crates/yakui-widgets/src/widgets/button.rs +++ b/crates/yakui-widgets/src/widgets/button.rs @@ -28,6 +28,7 @@ if yakui::button("Hello").clicked { */ #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Button { pub text: Cow<'static, str>, pub padding: Pad, diff --git a/crates/yakui-widgets/src/widgets/canvas.rs b/crates/yakui-widgets/src/widgets/canvas.rs index fc66be04..ea63fa10 100644 --- a/crates/yakui-widgets/src/widgets/canvas.rs +++ b/crates/yakui-widgets/src/widgets/canvas.rs @@ -12,6 +12,7 @@ Allows the user to draw arbitrary graphics in a region. Responds with [CanvasResponse]. */ #[derive(Debug)] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Canvas { draw: IgnoreDebug>, } diff --git a/crates/yakui-widgets/src/widgets/checkbox.rs b/crates/yakui-widgets/src/widgets/checkbox.rs index 26b6bb38..54a74c38 100644 --- a/crates/yakui-widgets/src/widgets/checkbox.rs +++ b/crates/yakui-widgets/src/widgets/checkbox.rs @@ -25,6 +25,7 @@ value = yakui::checkbox(value).checked; */ #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Checkbox { pub checked: bool, } diff --git a/crates/yakui-widgets/src/widgets/circle.rs b/crates/yakui-widgets/src/widgets/circle.rs index 9263b25d..210a2a5c 100644 --- a/crates/yakui-widgets/src/widgets/circle.rs +++ b/crates/yakui-widgets/src/widgets/circle.rs @@ -12,6 +12,7 @@ Responds with [CircleResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Circle { pub color: Color, pub min_radius: f32, diff --git a/crates/yakui-widgets/src/widgets/colored_box.rs b/crates/yakui-widgets/src/widgets/colored_box.rs index 88663499..efd65cee 100644 --- a/crates/yakui-widgets/src/widgets/colored_box.rs +++ b/crates/yakui-widgets/src/widgets/colored_box.rs @@ -12,6 +12,7 @@ Responds with [ColoredBoxResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct ColoredBox { pub color: Color, pub min_size: Vec2, diff --git a/crates/yakui-widgets/src/widgets/constrained_box.rs b/crates/yakui-widgets/src/widgets/constrained_box.rs index fed5b56e..57bda231 100644 --- a/crates/yakui-widgets/src/widgets/constrained_box.rs +++ b/crates/yakui-widgets/src/widgets/constrained_box.rs @@ -11,6 +11,7 @@ Responds with [ConstrainedBoxResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct ConstrainedBox { pub constraints: Constraints, } diff --git a/crates/yakui-widgets/src/widgets/count_grid.rs b/crates/yakui-widgets/src/widgets/count_grid.rs index d7e35347..aa1275be 100644 --- a/crates/yakui-widgets/src/widgets/count_grid.rs +++ b/crates/yakui-widgets/src/widgets/count_grid.rs @@ -28,6 +28,7 @@ Responds with [CountGridResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct CountGrid { pub direction: Direction, pub cross_axis_count: usize, diff --git a/crates/yakui-widgets/src/widgets/cutout.rs b/crates/yakui-widgets/src/widgets/cutout.rs index 11b28b0e..05aec1e7 100644 --- a/crates/yakui-widgets/src/widgets/cutout.rs +++ b/crates/yakui-widgets/src/widgets/cutout.rs @@ -13,6 +13,7 @@ Responds with [CutOutResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct CutOut { pub image: Option, pub image_color: Color, diff --git a/crates/yakui-widgets/src/widgets/divider.rs b/crates/yakui-widgets/src/widgets/divider.rs index 2c3a4587..ec14736e 100644 --- a/crates/yakui-widgets/src/widgets/divider.rs +++ b/crates/yakui-widgets/src/widgets/divider.rs @@ -8,6 +8,7 @@ use yakui_core::Response; /// Responds with [DividerResponse]. #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Divider { /// The color of the divider. pub color: Color, diff --git a/crates/yakui-widgets/src/widgets/draggable.rs b/crates/yakui-widgets/src/widgets/draggable.rs index 501751a7..6ef41ed6 100644 --- a/crates/yakui-widgets/src/widgets/draggable.rs +++ b/crates/yakui-widgets/src/widgets/draggable.rs @@ -8,6 +8,7 @@ use crate::util::widget_children; #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Draggable {} impl Draggable { diff --git a/crates/yakui-widgets/src/widgets/flexible.rs b/crates/yakui-widgets/src/widgets/flexible.rs index 7c2a60d0..356c1690 100644 --- a/crates/yakui-widgets/src/widgets/flexible.rs +++ b/crates/yakui-widgets/src/widgets/flexible.rs @@ -23,6 +23,7 @@ yakui::flexible(2, || { */ #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Flexible { pub flex: u32, pub fit: FlexFit, diff --git a/crates/yakui-widgets/src/widgets/image.rs b/crates/yakui-widgets/src/widgets/image.rs index 1b7d6484..099f1afc 100644 --- a/crates/yakui-widgets/src/widgets/image.rs +++ b/crates/yakui-widgets/src/widgets/image.rs @@ -12,6 +12,7 @@ Responds with [ImageResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Image { pub image: Option, pub size: Vec2, diff --git a/crates/yakui-widgets/src/widgets/layer.rs b/crates/yakui-widgets/src/widgets/layer.rs index e5287efc..cdb534f7 100644 --- a/crates/yakui-widgets/src/widgets/layer.rs +++ b/crates/yakui-widgets/src/widgets/layer.rs @@ -13,6 +13,7 @@ applied to layers. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Layer {} impl Layer { diff --git a/crates/yakui-widgets/src/widgets/list.rs b/crates/yakui-widgets/src/widgets/list.rs index 0233da6f..8cb9b935 100644 --- a/crates/yakui-widgets/src/widgets/list.rs +++ b/crates/yakui-widgets/src/widgets/list.rs @@ -27,6 +27,7 @@ yakui::row(|| { */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct List { pub direction: Direction, /// Added space at the end of each item. diff --git a/crates/yakui-widgets/src/widgets/max_width.rs b/crates/yakui-widgets/src/widgets/max_width.rs index 505e2bfa..1ac9f7d9 100644 --- a/crates/yakui-widgets/src/widgets/max_width.rs +++ b/crates/yakui-widgets/src/widgets/max_width.rs @@ -11,6 +11,7 @@ Responds with [MaxWidthResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct MaxWidth { pub max_width: f32, } diff --git a/crates/yakui-widgets/src/widgets/nineslice.rs b/crates/yakui-widgets/src/widgets/nineslice.rs index baafa76b..f0ac715b 100644 --- a/crates/yakui-widgets/src/widgets/nineslice.rs +++ b/crates/yakui-widgets/src/widgets/nineslice.rs @@ -8,6 +8,7 @@ use yakui_core::{ use crate::{shorthand::pad, util::widget_children, widgets::pad::Pad}; #[derive(Debug)] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct NineSlice { texture: ManagedTextureId, /// Texture margins in pixels around the central NineSlice region, before diff --git a/crates/yakui-widgets/src/widgets/offset.rs b/crates/yakui-widgets/src/widgets/offset.rs index 7361f777..75144eee 100644 --- a/crates/yakui-widgets/src/widgets/offset.rs +++ b/crates/yakui-widgets/src/widgets/offset.rs @@ -9,6 +9,7 @@ Offsets its child by the given number of logical pixels. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Offset { pub offset: Vec2, } diff --git a/crates/yakui-widgets/src/widgets/opaque.rs b/crates/yakui-widgets/src/widgets/opaque.rs index cc950636..9ed8079f 100644 --- a/crates/yakui-widgets/src/widgets/opaque.rs +++ b/crates/yakui-widgets/src/widgets/opaque.rs @@ -11,6 +11,7 @@ that don't want mouse input to go through them. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Opaque {} impl Opaque { diff --git a/crates/yakui-widgets/src/widgets/pad.rs b/crates/yakui-widgets/src/widgets/pad.rs index ab63eb6f..6e70d552 100644 --- a/crates/yakui-widgets/src/widgets/pad.rs +++ b/crates/yakui-widgets/src/widgets/pad.rs @@ -11,6 +11,7 @@ Responds with [PadResponse]. */ #[derive(Debug, Clone, Copy)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Pad { pub left: f32, pub right: f32, diff --git a/crates/yakui-widgets/src/widgets/panel.rs b/crates/yakui-widgets/src/widgets/panel.rs index d30621b4..92457aed 100644 --- a/crates/yakui-widgets/src/widgets/panel.rs +++ b/crates/yakui-widgets/src/widgets/panel.rs @@ -17,6 +17,7 @@ const _RESIZE_HANDLE_WIDTH: f32 = 6.0; /// detection and movement within a single widget? #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Panel { pub kind: PanelKind, } diff --git a/crates/yakui-widgets/src/widgets/reflow.rs b/crates/yakui-widgets/src/widgets/reflow.rs index f29af5fd..8e330f5c 100644 --- a/crates/yakui-widgets/src/widgets/reflow.rs +++ b/crates/yakui-widgets/src/widgets/reflow.rs @@ -10,6 +10,7 @@ or table layouts. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Reflow { pub anchor: Alignment, pub pivot: Pivot, diff --git a/crates/yakui-widgets/src/widgets/render_text.rs b/crates/yakui-widgets/src/widgets/render_text.rs index 9e661a98..45055b27 100644 --- a/crates/yakui-widgets/src/widgets/render_text.rs +++ b/crates/yakui-widgets/src/widgets/render_text.rs @@ -22,6 +22,7 @@ supports features like padding. */ #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct RenderText { pub text: Cow<'static, str>, pub style: TextStyle, diff --git a/crates/yakui-widgets/src/widgets/render_textbox.rs b/crates/yakui-widgets/src/widgets/render_textbox.rs index 50885c8b..29bc7d34 100644 --- a/crates/yakui-widgets/src/widgets/render_textbox.rs +++ b/crates/yakui-widgets/src/widgets/render_textbox.rs @@ -21,6 +21,7 @@ Responds with [RenderTextBoxResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct RenderTextBox { pub text: String, pub style: TextStyle, diff --git a/crates/yakui-widgets/src/widgets/round_rect.rs b/crates/yakui-widgets/src/widgets/round_rect.rs index 710c219a..074c5d6a 100644 --- a/crates/yakui-widgets/src/widgets/round_rect.rs +++ b/crates/yakui-widgets/src/widgets/round_rect.rs @@ -12,6 +12,7 @@ Responds with [RoundRectResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct RoundRect { pub radius: f32, pub color: Color, diff --git a/crates/yakui-widgets/src/widgets/scrollable.rs b/crates/yakui-widgets/src/widgets/scrollable.rs index d27eb9bb..167960b9 100644 --- a/crates/yakui-widgets/src/widgets/scrollable.rs +++ b/crates/yakui-widgets/src/widgets/scrollable.rs @@ -9,6 +9,7 @@ use crate::util::widget_children; #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Scrollable { pub direction: Option, } diff --git a/crates/yakui-widgets/src/widgets/slider.rs b/crates/yakui-widgets/src/widgets/slider.rs index 6fbb53d9..d81d78a1 100644 --- a/crates/yakui-widgets/src/widgets/slider.rs +++ b/crates/yakui-widgets/src/widgets/slider.rs @@ -18,6 +18,7 @@ const TOTAL_HEIGHT: f32 = KNOB_SIZE * 1.5; #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Slider { pub value: f64, pub min: f64, diff --git a/crates/yakui-widgets/src/widgets/spacer.rs b/crates/yakui-widgets/src/widgets/spacer.rs index ad88f3a7..8516769c 100644 --- a/crates/yakui-widgets/src/widgets/spacer.rs +++ b/crates/yakui-widgets/src/widgets/spacer.rs @@ -11,6 +11,7 @@ use crate::util::widget; /// Responds with [SpacerResponse]. #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Spacer { pub flex: u32, } diff --git a/crates/yakui-widgets/src/widgets/state.rs b/crates/yakui-widgets/src/widgets/state.rs index 3f9a03ae..f4a808d2 100644 --- a/crates/yakui-widgets/src/widgets/state.rs +++ b/crates/yakui-widgets/src/widgets/state.rs @@ -7,6 +7,7 @@ use yakui_core::Response; use crate::util; +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct State { default: Box T>, } diff --git a/crates/yakui-widgets/src/widgets/text.rs b/crates/yakui-widgets/src/widgets/text.rs index d39c9edb..c6ca17f0 100644 --- a/crates/yakui-widgets/src/widgets/text.rs +++ b/crates/yakui-widgets/src/widgets/text.rs @@ -29,6 +29,7 @@ text.show(); */ #[derive(Debug)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Text { pub text: Cow<'static, str>, pub style: TextStyle, diff --git a/crates/yakui-widgets/src/widgets/textbox.rs b/crates/yakui-widgets/src/widgets/textbox.rs index 877eee8b..9c941fed 100644 --- a/crates/yakui-widgets/src/widgets/textbox.rs +++ b/crates/yakui-widgets/src/widgets/textbox.rs @@ -24,6 +24,7 @@ Responds with [TextBoxResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct TextBox { pub text: String, pub style: TextStyle, diff --git a/crates/yakui-widgets/src/widgets/unconstrained_box.rs b/crates/yakui-widgets/src/widgets/unconstrained_box.rs index 45ce2480..01a42980 100644 --- a/crates/yakui-widgets/src/widgets/unconstrained_box.rs +++ b/crates/yakui-widgets/src/widgets/unconstrained_box.rs @@ -11,6 +11,7 @@ Responds with [UnconstrainedBoxResponse]. */ #[derive(Debug, Clone)] #[non_exhaustive] +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct UnconstrainedBox { pub constrain_x: bool, pub constrain_y: bool, diff --git a/crates/yakui-widgets/src/widgets/window.rs b/crates/yakui-widgets/src/widgets/window.rs index e6b8910d..9f835163 100644 --- a/crates/yakui-widgets/src/widgets/window.rs +++ b/crates/yakui-widgets/src/widgets/window.rs @@ -13,6 +13,7 @@ A floating window within the application. Responds with [WindowResponse]. */ +#[must_use = "yakui widgets do nothing if you don't `show` them"] pub struct Window { pub initial_size: Vec2, children: Option>,