Use explicit return statement TaskStorage::spawn

This commit removes the else branch in TaskStorage::spawn, and returns
explicitly from the if statement's branch, similar to what
TaskPool::spawn does.
This commit is contained in:
Daniel Bevenius 2022-05-04 16:11:23 +02:00
parent 85c0525e01
commit 34493c7ed6

View File

@ -165,10 +165,10 @@ impl<F: Future + 'static> TaskStorage<F> {
/// on a different executor.
pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken<impl Sized> {
if self.spawn_mark_used() {
unsafe { SpawnToken::<F>::new(self.spawn_initialize(future)) }
} else {
SpawnToken::<F>::new_failed()
return unsafe { SpawnToken::<F>::new(self.spawn_initialize(future)) }
}
SpawnToken::<F>::new_failed()
}
fn spawn_mark_used(&'static self) -> bool {