rust-itertools / itertools

Extra iterator adaptors, iterator methods, free functions, and macros.
https://docs.rs/itertools/
Apache License 2.0
2.72k stars 309 forks source link

converting Vec<Vec<u8>> to Vec<u8> #655

Closed bobi6666 closed 9 months ago

bobi6666 commented 1 year ago

Hello, I would like to ask if itertools includes something like flat_map? because I would need to convert Vec<Vec> so that at the end it becomes Vec but with the fact that between each iteration a separator would be inserted, for example 47, which represents the character / and it would be a delimiter.

scottmcm commented 1 year ago

Can you show what you're doing, and how it works with, say, https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.format or https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.intersperse today?

bobi6666 commented 1 year ago

thanks i used intersperse and converted Vec<Vec> to Vec like that: let final_vec: Vec = itertools::intersperse(temp_vec.into_iter(), Vec::from("/")) .flatten() .chain(once(0)) .collect(); i hope it is the best step i can do about performance

2022-11-09 7:53 GMT+01:00, scottmcm @.***>:

Can you show what you're doing, and how it works with, say, https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.format or https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.intersperse today?

-- Reply to this email directly or view it on GitHub: https://github.com/rust-itertools/itertools/issues/655#issuecomment-1308293694 You are receiving this because you authored the thread.

Message ID: @.***>