Skip to content

Commit

Permalink
std: Add FromIterator trait
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Feb 9, 2025
1 parent 8586ab3 commit 9f20167
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkgs/std/traits.dora
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ pub trait Iterator {
fn map[R](f: (Self::Item): R): Map[Self, R] {
Map[Self, R](it = self, fct = f)
}

// @TraitObjectIgnore
// fn collect[X: FromIterator[Self::Item]](): X {
// X::fromIter(self)
// }
}

pub trait IntoIterator {
Expand Down Expand Up @@ -207,6 +212,10 @@ impl[I: Iterator, R] Iterator for Map[I, R] {
}
}

pub trait FromIterator[A] {
fn fromIter[T](iter: T): Self where T: Iterator[Item=A];
}

pub trait IndexGet {
type Index;
type Item;
Expand Down

0 comments on commit 9f20167

Please sign in to comment.