From 08a4179e7e3ea91cb63c07b71afae4780005cfd6 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 13 Jan 2021 11:24:49 +0100 Subject: [PATCH] Add #[must_use] to all widget builders --- egui/src/widgets/button.rs | 1 + egui/src/widgets/drag_value.rs | 1 + egui/src/widgets/slider.rs | 1 + egui/src/widgets/text_edit.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/egui/src/widgets/button.rs b/egui/src/widgets/button.rs index c863e51b..5b7ce421 100644 --- a/egui/src/widgets/button.rs +++ b/egui/src/widgets/button.rs @@ -136,6 +136,7 @@ impl Widget for Button { // TODO: allow checkbox without a text label /// Boolean on/off control with text label. +#[must_use = "You should put this widget in an ui with `ui.add(widget);`"] #[derive(Debug)] pub struct Checkbox<'a> { checked: &'a mut bool, diff --git a/egui/src/widgets/drag_value.rs b/egui/src/widgets/drag_value.rs index 0a369bf2..0eb33730 100644 --- a/egui/src/widgets/drag_value.rs +++ b/egui/src/widgets/drag_value.rs @@ -17,6 +17,7 @@ fn set(value_function: &mut GetSetValue<'_>, value: f64) { } /// A numeric value that you can change by dragging the number. More compact than a [`Slider`]. +#[must_use = "You should put this widget in an ui with `ui.add(widget);`"] pub struct DragValue<'a> { value_function: GetSetValue<'a>, speed: f32, diff --git a/egui/src/widgets/slider.rs b/egui/src/widgets/slider.rs index 4d84bb7c..d3aae681 100644 --- a/egui/src/widgets/slider.rs +++ b/egui/src/widgets/slider.rs @@ -37,6 +37,7 @@ struct SliderSpec { /// Control a number by a horizontal slider. /// The range can include any numbers, and go from low-to-high or from high-to-low. +#[must_use = "You should put this widget in an ui with `ui.add(widget);`"] pub struct Slider<'a> { get_set_value: GetSetValue<'a>, range: RangeInclusive, diff --git a/egui/src/widgets/text_edit.rs b/egui/src/widgets/text_edit.rs index 1e4f9f98..b90c2e2b 100644 --- a/egui/src/widgets/text_edit.rs +++ b/egui/src/widgets/text_edit.rs @@ -119,6 +119,7 @@ impl CCursorPair { /// // use my_string /// } /// ``` +#[must_use = "You should put this widget in an ui with `ui.add(widget);`"] #[derive(Debug)] pub struct TextEdit<'t> { text: &'t mut String,