Skip to content

Commit

Permalink
let-else (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
asukaminato0721 authored Nov 8, 2023
1 parent f8a1719 commit 6716304
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/batch_shuffle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ where
I: Clone + Send + Sync,
{
fn get(&self, index: usize) -> Option<I> {
if let Some(index) = self.indices.get(index) {
self.dataset.get(*index)
} else {
None
}
let Some(index) = self.indices.get(index) else {
return None;
};
self.dataset.get(*index)
}

fn len(&self) -> usize {
Expand Down Expand Up @@ -247,11 +246,11 @@ impl<I, O> Iterator for BatchShuffledDataloaderIterator<I, O> {
}
}

if let Some(items) = self.strategy.batch(true) {
return Some(self.batcher.batch(items));
}
let Some(items) = self.strategy.batch(true) else {
return None;
};

None
Some(self.batcher.batch(items))
}
}

Expand Down

0 comments on commit 6716304

Please sign in to comment.