Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/bowling/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Frame {
return self.bonus_score() <= 10;
}

if let Some(first) = self.bonus.iter().next() {
if let Some(first) = self.bonus.get(0) {
if *first == 10 {
self.bonus_score() <= 20
} else {
Expand Down
2 changes: 1 addition & 1 deletion exercises/doubly-linked-list/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<T> LinkedList<T> {
impl<T> Drop for LinkedList<T> {
fn drop(&mut self) {
let mut cursor = self.cursor_front();
while let Some(_) = cursor.take() {}
while cursor.take().is_some() {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion exercises/fizzy/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ mod test {
"fizz", "fizz", "fizz", "buzz", "buzz", "16", "8", "4", "2", "1",
];
let got = fizz_buzz()
.apply(collatz_12.into_iter().cloned())
.apply(collatz_12.iter().cloned())
.collect::<Vec<_>>();
assert_eq!(expect, got);
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/forth/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Forth {
}

fn pop_two(&mut self) -> StackResult<(Value, Value)> {
self.pop().and_then(|b| self.pop().and_then(|a| Ok((a, b))))
self.pop().and_then(|b| self.pop().map(|a| (a, b)))
}

fn bin_op<F>(&mut self, op: F) -> ForthResult
Expand Down
2 changes: 1 addition & 1 deletion exercises/phone-number/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn number(user_number: &str) -> Option<String> {

if number_len < 10
|| number_len > 11
|| (filtered_number.len() == 11 && filtered_number.chars().next().unwrap() != '1')
|| (filtered_number.len() == 11 && !filtered_number.starts_with('1'))
{
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/poker/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use counter::Counter;
/// the winning hand(s) as were passed in, not reconstructed strings which happen to be equal.
pub fn winning_hands<'a>(hands: &[&'a str]) -> Option<Vec<&'a str>> {
let mut hands = hands
.into_iter()
.iter()
.map(|source| Hand::try_from(*source))
.collect::<Result<Vec<_>, _>>().ok()?;
hands.sort_by(|a, b| a.partial_cmp(b).unwrap_or(Ordering::Less));
Expand Down
10 changes: 4 additions & 6 deletions exercises/rail-fence-cipher/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ impl RailFence {
*down = false;
*rail -= 1;
}
} else if *rail > 0 {
*rail -= 1;
} else {
if *rail > 0 {
*rail -= 1;
} else {
*down = true;
*rail += 1;
}
*down = true;
*rail += 1;
}
}

Expand Down