sink in alloc::io - Rust
Description: Creates an instance of a writer which will successfully consume all data.

Skip to main content

## sink

# Function sink

const: 1.79.0 · Source

    pub const fn sink() -> Sink

🔬This is a nightly-only experimental API. (`alloc_io` #154046)
Expand description

Creates an instance of a writer which will successfully consume all data.

All calls to `write` on the returned instance will return `Ok(buf.len())` and the contents of the buffer will not be inspected.

## §Examples

    use std::io::{self, Write};

    let buffer = vec![1, 2, 3, 5, 8];
    let num_bytes = io::sink().write(&buffer).unwrap();
    assert_eq!(num_bytes, 5);