# Function futures::future::lazy [−] [src]

    pub fn lazy<F, R>(f: F) -> Lazy<F, R> where
        F: FnOnce() -> R,
        R: IntoFuture,

Creates a new future which will eventually be the same as the one created by the closure provided.

The provided closure is only run once the future has a callback scheduled on it, otherwise the callback never runs. Once run, however, this future is the same as the one the closure creates.

# Examples

    use futures::future::*;

    let a = lazy(|| ok::<u32, u32>(1));

    let b = lazy(|| -> FutureResult<u32, u32> {
        panic!("oh no!")
    });
    drop(b); // closure is never run

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)