Help with a BTreemap extract

Hi guys,

pub struct Value {
    pub list: Vec<[u8;32]>,
    pub empty: bool
}


impl DataMap {

    // This needs to be done at the end as it will take the Ownership of the map
    pub fn extract(&self) -> Vec<[u8;32]> {

        // This use rayon to parallelize the reading from the BTreemap
        self.par_iter().flat_map(|(_, v)| v.list.clone()).collect()
    }

}

My code right now is working, with Rayon, taking the content of the struct Value and put them all inside an array.
I'd like to at the same time take the content of v.list and copy it into another array and do something with it.

Example:

pub fn extract(&self) -> Vec<[u8;32]> {

    // This use rayon to parallelize the reading from the BTreemap
    self.par_iter().flat_map(|(_, v)| v.list.clone()).collect()

    // before returning, do an operation on v.list (for each Key) call fn_process(list_inside)
    // For each key, i'd like to call a function with the "list" field from the struct
}

Thank you so much again

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.