Add #[must_use] to container types: remind to call show()

This commit is contained in:
Emil Ernerfeldt 2021-05-20 21:45:00 +02:00
parent a892519297
commit 94479317b3
9 changed files with 11 additions and 0 deletions

View file

@ -40,6 +40,7 @@ impl State {
/// .show(ctx, |ui| { /// .show(ctx, |ui| {
/// ui.label("Floating text!"); /// ui.label("Floating text!");
/// }); /// });
#[must_use = "You should call .show()"]
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub struct Area { pub struct Area {
pub(crate) id: Id, pub(crate) id: Id,

View file

@ -134,6 +134,7 @@ pub(crate) fn paint_icon(ui: &mut Ui, openness: f32, response: &Response) {
/// // Short version: /// // Short version:
/// ui.collapsing("Heading", |ui| { ui.label("Contents"); }); /// ui.collapsing("Heading", |ui| { ui.label("Contents"); });
/// ``` /// ```
#[must_use = "You should call .show()"]
pub struct CollapsingHeader { pub struct CollapsingHeader {
label: Label, label: Label,
default_open: bool, default_open: bool,

View file

@ -19,6 +19,7 @@ use epaint::Shape;
/// } /// }
/// ); /// );
/// ``` /// ```
#[must_use = "You should call .show*"]
pub struct ComboBox { pub struct ComboBox {
id_source: Id, id_source: Id,
label: Option<Label>, label: Option<Label>,

View file

@ -5,6 +5,7 @@ use epaint::*;
/// Color and margin of a rectangular background of a [`Ui`]. /// Color and margin of a rectangular background of a [`Ui`].
#[derive(Clone, Copy, Debug, Default, PartialEq)] #[derive(Clone, Copy, Debug, Default, PartialEq)]
#[must_use = "You should call .show()"]
pub struct Frame { pub struct Frame {
/// On each side /// On each side
pub margin: Vec2, pub margin: Vec2,

View file

@ -23,6 +23,7 @@ use crate::*;
/// ui.label("Hello World!"); /// ui.label("Hello World!");
/// }); /// });
/// ``` /// ```
#[must_use = "You should call .show()"]
pub struct SidePanel { pub struct SidePanel {
id: Id, id: Id,
max_width: f32, max_width: f32,
@ -95,6 +96,7 @@ impl SidePanel {
/// ui.label("Hello World!"); /// ui.label("Hello World!");
/// }); /// });
/// ``` /// ```
#[must_use = "You should call .show()"]
pub struct TopPanel { pub struct TopPanel {
id: Id, id: Id,
max_height: Option<f32>, max_height: Option<f32>,
@ -171,6 +173,7 @@ impl TopPanel {
/// ui.label("Hello World!"); /// ui.label("Hello World!");
/// }); /// });
/// ``` /// ```
#[must_use = "You should call .show()"]
#[derive(Default)] #[derive(Default)]
pub struct CentralPanel { pub struct CentralPanel {
frame: Option<Frame>, frame: Option<Frame>,

View file

@ -18,6 +18,7 @@ pub(crate) struct State {
/// A region that can be resized by dragging the bottom right corner. /// A region that can be resized by dragging the bottom right corner.
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
#[must_use = "You should call .show()"]
pub struct Resize { pub struct Resize {
id: Option<Id>, id: Option<Id>,
id_source: Option<Id>, id_source: Option<Id>,

View file

@ -30,6 +30,7 @@ impl Default for State {
// TODO: rename VScroll // TODO: rename VScroll
/// Add vertical scrolling to a contained [`Ui`]. /// Add vertical scrolling to a contained [`Ui`].
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[must_use = "You should call .show()"]
pub struct ScrollArea { pub struct ScrollArea {
max_height: f32, max_height: f32,
always_show_scroll: bool, always_show_scroll: bool,

View file

@ -21,6 +21,7 @@ use super::*;
/// egui::Window::new("My Window").show(ctx, |ui| { /// egui::Window::new("My Window").show(ctx, |ui| {
/// ui.label("Hello World!"); /// ui.label("Hello World!");
/// }); /// });
#[must_use = "You should call .show()"]
pub struct Window<'open> { pub struct Window<'open> {
title_label: Label, title_label: Label,
open: Option<&'open mut bool>, open: Option<&'open mut bool>,

View file

@ -246,6 +246,7 @@ impl GridLayout {
/// ui.end_row(); /// ui.end_row();
/// }); /// });
/// ``` /// ```
#[must_use = "You should call .show()"]
pub struct Grid { pub struct Grid {
id_source: Id, id_source: Id,
striped: bool, striped: bool,