Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pile improvements 1 #233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

hydra
Copy link
Contributor

@hydra hydra commented Dec 17, 2024

Improvements based on discoveries made in #231

Copy link
Member

@ecton ecton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great finds about the missing must_uses. I even explicitly disabled it in one location as you can see with one of the suggested edits on this PR.

@@ -185,6 +192,12 @@ impl std::ops::Deref for PendingPiledWidget {
}

/// A widget that has been added to a [`Pile`].
///
/// If this is dropped, the widget will be removed from the Pile.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// If this is dropped, the widget will be removed from the Pile.
/// When the last clone of a `PiledWidget` is dropped, the widget will be removed from the Pile.

@@ -218,6 +231,7 @@ struct PiledWidgetData {

impl Drop for PiledWidgetData {
fn drop(&mut self) {
println!("drop called");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
println!("drop called");

@@ -67,6 +69,9 @@ impl Pile {
/// When the last clone of the returned [`PiledWidget`] is dropped, `widget`
/// will be removed from the pile. If it is the currently visible widget,
/// the next widget in the pile will be made visible.
///
/// See [`PiledWidget`] for important lifetime information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the paragraph directly before this statement explain what the summary added to PiledWidget states?

@@ -49,6 +49,8 @@ impl PileData {
impl Pile {
/// Returns a placeholder that can be used to show/close a piled widget
/// before it has been constructed.
///
/// See [`PiledWidget`] for important lifetime information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type of this function isn't a PiledWidget but a PendingPIledWidget, so this tip seems wrong.

@@ -164,6 +169,8 @@ pub struct PendingPiledWidget(Option<PiledWidget>);

impl PendingPiledWidget {
/// Place `widget` in the pile and returns a handle to the placed widget.
///
/// See [`PiledWidget`] for important lifetime information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// See [`PiledWidget`] for important lifetime information.
/// When the last clone of the returned [`PiledWidget`] is dropped, `widget`
/// will be removed from the pile. If it is the currently visible widget,
/// the next widget in the pile will be made visible.

I prefer not making the user jump through links to read information like this. I've pasted the summary from push as the suggestion here.

@@ -164,6 +169,8 @@ pub struct PendingPiledWidget(Option<PiledWidget>);

impl PendingPiledWidget {
/// Place `widget` in the pile and returns a handle to the placed widget.
///
/// See [`PiledWidget`] for important lifetime information.
#[allow(clippy::must_use_candidate)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[allow(clippy::must_use_candidate)]
#[must_use]

This seems like an oversight by me.

/// Lifetimes:
///
/// Due to how this macro works variables in the closure will be dropped at the end of the
/// method body, and *NOT* when the application terminates.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test that this documentation shows up when running cargo doc? I ask because this macro already has documentation in another location:

cushy/src/lib.rs

Lines 46 to 47 in f6a4704

/// The function body is executed during application startup, and the app will
/// continue running until the last window is closed.

I linked to the paragraph where I tried to explain what is happening. It seems like that should be updated to be more explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants