add FromIterator for Block/Module and make code succinct

This commit is contained in:
Yuna Tomida 2022-11-08 01:54:10 +09:00
parent 14b143778f
commit be5a79a4b0
No known key found for this signature in database
GPG key ID: 3446B3EBE0190A4E
2 changed files with 22 additions and 18 deletions

View file

@ -1124,6 +1124,12 @@ impl Locational for Block {
}
}
impl FromIterator<Expr> for Block {
fn from_iter<T: IntoIterator<Item = Expr>>(iter: T) -> Self {
Self(iter.into_iter().collect())
}
}
impl_stream_for_wrapper!(Block, Expr);
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
@ -3438,6 +3444,12 @@ impl Stream<Expr> for Module {
}
}
impl FromIterator<Expr> for Module {
fn from_iter<T: IntoIterator<Item = Expr>>(iter: T) -> Self {
Self(iter.into_iter().collect())
}
}
impl Module {
pub const fn empty() -> Self {
Self(Block::empty())