-
Notifications
You must be signed in to change notification settings - Fork 12
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
Submit assignment #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
I also noticed the file had a bunch of tabs in it. Rust opts for spaces, and there should be a way to tell your editor to use them.
else { | ||
Ok(NextStep::Continue) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be more idomatic to use match
rather than if/else
with an unwrap. Generally avoiding unwrap is good, because it makes it easier to very that code will execute without panicking.
} | ||
|
||
/// Returns true if the game has been won! | ||
fn done(&self) -> bool { | ||
unimplemented!() | ||
//We always start the game with a stack on the left peg, so check if two pegs (one of which is the left peg) are empty | ||
self.get_tower(Peg::Left).is_empty() && (self.get_tower(Peg::Center).is_empty() || self.get_tower(Peg::Right).is_empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust convention is to enforce a 100 character limit on lines.
let mut starting_vector: Vec<Disk> = Vec::new(); | ||
for size in 0..disks { | ||
starting_vector.push(Disk(disks-size)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can turn a range like 0..disks
(or any iterator) into a vector using Iterator::collect
. See the sample solution!
No description provided.