mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-01 13:11:11 +00:00
add FromIterator for Block/Module and make code succinct
This commit is contained in:
parent
14b143778f
commit
be5a79a4b0
2 changed files with 22 additions and 18 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue