Thanks for all your work on Smol and associated crates. I'm learning a lot from reading the code and enjoy using the small apis. While reading through I came across what I think is a bug in the implementation of race.
if fastrand::bool() {
if let Poll::Ready(t) = this.future1.poll(cx) {
return Poll::Ready(t);
}
if let Poll::Ready(t) = this.future2.poll(cx) {
return Poll::Ready(t);
}
} else {
if let Poll::Ready(t) = this.future1.poll(cx) {
return Poll::Ready(t);
}
if let Poll::Ready(t) = this.future2.poll(cx) {
return Poll::Ready(t);
}
I might be missing a subtle point, but shouldn't that be:
if fastrand::bool() {
if let Poll::Ready(t) = this.future1.poll(cx) {
return Poll::Ready(t);
}
if let Poll::Ready(t) = this.future2.poll(cx) {
return Poll::Ready(t);
}
} else {
if let Poll::Ready(t) = this.future2.poll(cx) {
return Poll::Ready(t);
}
if let Poll::Ready(t) = this.future1.poll(cx) {
return Poll::Ready(t);
}
To switch the order the futures get polled in the else branch.
Thanks for all your work on Smol and associated crates. I'm learning a lot from reading the code and enjoy using the small apis. While reading through I came across what I think is a bug in the implementation of race.
https://github.com/stjepang/futures-lite/blob/master/src/future.rs#L504-L517
I might be missing a subtle point, but shouldn't that be:
To switch the order the futures get polled in the else branch.