Skip to content

Conversation

treeman
Copy link
Contributor

@treeman treeman commented Jul 21, 2014

I wanted to have a slightly larger example compared to the method examples, but I'm unsure how it worked out.

Feedback would nice.

//! #[deriving(Eq, PartialEq)]
//! struct State {
//! cost: uint,
//! pos: uint
Copy link
Contributor

Choose a reason for hiding this comment

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

bikeshed alert: wonder if this shouldn't be a full position instead. It's not that much longer.

@steveklabnik
Copy link
Contributor

I really like this idea.

@treeman
Copy link
Contributor Author

treeman commented Jul 22, 2014

Great! Thanks for the pointers.

//!
//! // Examine the frontier with lower cost nodes first (min-heap)
//! while !pq.is_empty() {
//! let State { position: u, cost: curr_cost } = pq.pop().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be

loop {
    let State { position, cost } = match pq.pop() {
        None => break, // empty
        Some(s) => s
    };

    // ...
}

@alexcrichton
Copy link
Member

This is a fantastic example, nice job!

This looks good to go with two minor comments and some squashings, thanks!

@treeman
Copy link
Contributor Author

treeman commented Jul 22, 2014

Cool, thanks!

bors added a commit that referenced this pull request Jul 22, 2014
I wanted to have a slightly larger example compared to the method examples, but I'm unsure how it worked out.

Feedback would nice.
@bors bors closed this Jul 22, 2014
@bors bors merged commit 94500b8 into rust-lang:master Jul 22, 2014
@treeman treeman deleted the doc-dijkstra-example branch September 17, 2014 09:50
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 4, 2023
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.

5 participants