# sleep

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-view/async_data/function-sleep/

**function** · [`ferroui-view`](/docs/0.5.0/api/ferroui-view/) · v0.5.0

```rust
fn sleep(duration: std::time::Duration) -> impl Future<Output = ()>
```

A future that ends after `duration`, on a timer of the dispatcher of the
thread: for a delay in a future of [`use_future`](/docs/0.5.0/api/ferroui-view/async_data/function-use_future/), such as the debouncing
of what the user types. The timer starts when the future is first polled;
a sleep dropped before it ends (its future was abandoned) stops it.

```ignore
let results = use_future(query.get(), |query| {
    let query = query.clone();
    async move {
        sleep(Duration::from_millis(300)).await;
        search(&query).await
    }
});
```

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/async_data.rs#L274)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
