Clock proposal calls out 3 ways of sleeping, 2 on
Task and 1 on
Task.sleep(until:) // Instant-based Task.sleep(for:) // Duration-based clock.sleep(until:) // Instant-based
However, there is no corresponding duration-based sleep for clocks:
clock.sleep(for:) // ❌ Duration-based
This means in order to perform duration-based sleeping, which is usually more ergonomic, you have to resort to the longer
try await Task.sleep(for: .seconds(1), clock: myClock) // vs try await myClock.sleep(for: .seconds(1))
Should this 4th variation of sleep be added to the standard library to be consistent?