dh::data

Function close

source
pub fn close<T: Into<ClosableData>>(closable: T) -> Vec<u8>
Expand description

Closes a reader, writer, or reader and writer and returns the data the structure was holding.

Note: This function only takes RData, WData, and RwData as input.

For references, please use the close_ref and close_mut functions.

ยงExample

use dh::recommended::*;

let data = vec![0, 1, 2, 3, 4, 5, 6, 7];
let clone = data.clone();
let mut reader = dh::data::read(data);

// do something with the reader

let data = dh::data::close(reader); // gets the data back
assert_eq!(data, clone);