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

Add BookmarkList example #1347

Closed
wants to merge 10 commits into from
Closed

Conversation

vanillajonathan
Copy link

Add example for #1346.

@bilelmoussaoui
Copy link
Member

I was expecting a proper example in https://github.com/gtk-rs/gtk4-rs/tree/master/examples instead

@vanillajonathan
Copy link
Author

Oh yeah, that is a good idea too!

I was thinking of having a example section in the docblock to sit shows in the documentation and when using the "Go to definition" in the IDE.

Does this project accept examples in the docblock too?

/// To iterate over `BookmarkList` call `iter::<gio::FileInfo>` to get an iterator.
/// ```no_run
/// let bookmarks = gtk::BookmarkList::new(Some("bookmarks.xbel"), None);
/// for bookmark in bookmarks.iter::<gio::FileInfo>() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This example looks weird to rust ppl I think.

Would it better to use

while let Some(Ok(bookmark)) = bookmarks.iter::<gio::FileInfo>().next() {
    // ...
}

Copy link
Author

Choose a reason for hiding this comment

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

@bilelmoussaoui What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with what @zekefast said. Although, does this example shows in the docs?

Copy link
Author

Choose a reason for hiding this comment

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

Okay I updated the PR with the example provided by @zekefast. I am not sure, but it should show up when you press F12 in VS Code.

Copy link
Member

Choose a reason for hiding this comment

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

You would have to resolve merge conflicts, the PR as is can't be tested by the CI nor merged

@bilelmoussaoui
Copy link
Member

Please test locally first....

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.

3 participants