FromIterator

์–ด๋–ค ์ปฌ๋ ‰์…˜์ด FromIterator๋ฅผ ๊ตฌํ˜„ํ•˜๊ณ  ์žˆ๋‹ค๋ฉด Iterator๋กœ๋ถ€ํ„ฐ ๊ทธ ์ปฌ๋ ‰์…˜์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

fn main() {
    let primes = vec![2, 3, 5, 7];
    let prime_squares = primes
        .into_iter()
        .map(|prime| prime * prime)
        .collect::<Vec<_>>();
}

Iterator์—๋Š” ๋‹ค์Œ ํ•จ์ˆ˜๊ฐ€ ์ •์˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค: fn collect<B>(self) -> B where B: FromIterator<Self::Item>, Self: Sized

Iterator<Item = Result<V, E>>์„ Result<Vec<V>, E>๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ‹์ง„ ๊ธฐ๋Šฅ๋“ค๋„ ๊ตฌํ˜„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.