midi_toolkit/sequence/common/
to_vec.rs

1use std::iter::FromIterator;
2
3/// Converts an iterator into a vector.
4///
5/// Useful when you to cache the result of an iterator for future use.
6///
7/// Unwraps all results from the iterator items.
8pub fn to_vec<T, I: Iterator<Item = T> + Sized>(iter: I) -> Vec<T> {
9    FromIterator::from_iter(iter)
10}
11
12/// Converts a result iterator into a vector result.
13///
14/// Useful when you to cache the result of an iterator for future use.
15///
16/// Unwraps all results from the iterator items.
17pub fn to_vec_result<T, Err, I: Iterator<Item = Result<T, Err>> + Sized>(
18    iter: I,
19) -> Result<Vec<T>, Err> {
20    FromIterator::from_iter(iter)
21}