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| {
/// ui.label("Floating text!");
/// });
#[must_use = "You should call .show()"]
#[derive(Clone, Copy, Debug)]
pub struct Area {
pub(crate) id: Id,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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