[][src]Trait rscache::LinkedListExt

pub trait LinkedListExt {
    fn to_vec(&self) -> Vec<u8>;
}

Adds extensions onto the std collection: LinkedList<T>.

Required methods

fn to_vec(&self) -> Vec<u8>

Loading content...

Implementations on Foreign Types

impl<'_> LinkedListExt for LinkedList<&'_ [u8]>[src]

fn to_vec(&self) -> Vec<u8>[src]

Iterates through the LinkedList<&[u8]> and copies the bytes into one owned buffer.

This function allocates a new buffer that is exactly large enough to hold all the slices combined that the LinkedList references. copy_from_slice() is used for high performance and to keep the amount of copies to a minimum.

Examples

Detailed example:

use std::collections::LinkedList;
use rscache::LinkedListExt;
 
let buffer: LinkedList<&[u8]> = cache.read(index_id, archive_id)?;
let buffer: Vec<u8> = buffer.to_vec();

Which can also be written as:

let buffer = cache.read(index_id, archive_id)?.to_vec();
Loading content...

Implementors

Loading content...