le_stream/from_le_stream/
std.rs1#![cfg(feature = "std")]
2
3use alloc::boxed::Box;
4use alloc::vec::Vec;
5use core::iter::once;
6
7use crate::FromLeStream;
8
9impl<T> FromLeStream for Vec<T>
10where
11 T: FromLeStream,
12{
13 fn from_le_stream<I>(mut bytes: I) -> Option<Self>
14 where
15 I: Iterator<Item = u8>,
16 {
17 let mut result = Self::new();
18
19 while let Some(byte) = bytes.next() {
20 result.push(T::from_le_stream(once(byte).chain(&mut bytes))?);
21 }
22
23 Some(result)
24 }
25}
26
27impl<T> FromLeStream for Box<[T]>
28where
29 T: FromLeStream,
30{
31 fn from_le_stream<I>(mut bytes: I) -> Option<Self>
32 where
33 I: Iterator<Item = u8>,
34 {
35 Vec::from_le_stream(&mut bytes).map(Vec::into_boxed_slice)
36 }
37}