Skip to content

Commit

Permalink
added must-use to widgets (SecondHalfGames#188)
Browse files Browse the repository at this point in the history
added
  • Loading branch information
sanbox-irl authored and msparkles committed Sep 10, 2024
1 parent 8645b3d commit c9ed54c
Show file tree
Hide file tree
Showing 32 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 alignment: Alignment,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<DrawCallback>>,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/colored_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/constrained_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/count_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/cutout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextureId>,
pub image_color: Color,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/divider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/draggable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/flexible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextureId>,
pub size: Vec2,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/max_width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/nineslice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/pad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/reflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/render_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Responds with [RenderTextBoxResponse].
*/
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
#[must_use = "yakui widgets do nothing if you don't `show` them"]
pub struct RenderText {
pub text: String,
pub style: TextStyle,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/round_rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ScrollDirection>,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/spacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
default: Box<dyn FnOnce() -> T>,
}
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 update_text: Option<String>,

Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/unconstrained_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/yakui-widgets/src/widgets/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<dyn Fn()>>,
Expand Down

0 comments on commit c9ed54c

Please sign in to comment.