Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stdlib] Fix iterator ergonomics #3700

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f726e54
fix iterator ergonomics
martinvuyk Oct 22, 2024
a68b635
fix detail
martinvuyk Oct 22, 2024
71540b0
fix details
martinvuyk Oct 22, 2024
4d0be8d
fix details
martinvuyk Oct 22, 2024
e8ffe4e
fix details
martinvuyk Oct 22, 2024
cf47de2
fix details
martinvuyk Oct 22, 2024
46b8ae3
fix details
martinvuyk Oct 22, 2024
42b23eb
fix details
martinvuyk Oct 22, 2024
b02899e
fix detail
martinvuyk Oct 22, 2024
542d409
revert name change and add next methods
martinvuyk Oct 22, 2024
44549b9
Merge branch 'nightly' into fix-iter-ergonomics
martinvuyk Oct 22, 2024
9cd0a28
fix detail
martinvuyk Oct 22, 2024
868f3f6
Merge branch 'fix-iter-ergonomics' of github.com:martinvuyk/mojo into…
martinvuyk Oct 22, 2024
393a9ec
Merge branch 'nightly' into fix-iter-ergonomics
martinvuyk Nov 6, 2024
f8c0591
fix __hasmore__ -> __has_next__
martinvuyk Nov 6, 2024
9adce79
remove bool dunders
martinvuyk Nov 15, 2024
6be47a6
Merge remote-tracking branch 'upstream/nightly' into fix-iter-ergonomics
martinvuyk Nov 15, 2024
733a600
mojo format
martinvuyk Nov 15, 2024
aba3216
fix remove use of bool
martinvuyk Nov 15, 2024
45b719d
fix the todo items to make them realistic
martinvuyk Nov 15, 2024
fb5f04e
fix detail
martinvuyk Nov 15, 2024
ea1370a
Merge remote-tracking branch 'upstream/nightly' into fix-iter-ergonomics
martinvuyk Nov 21, 2024
7b02d0a
add iter and reserved explicitly to string, stringliteral, and string…
martinvuyk Nov 21, 2024
0ee6e6b
fix detail in string_slice test
martinvuyk Nov 21, 2024
150dbb5
Merge remote-tracking branch 'upstream/nightly' into fix-iter-ergonomics
martinvuyk Dec 10, 2024
be2dfd6
fix details after merge
martinvuyk Dec 10, 2024
9ec7b45
fix details
martinvuyk Dec 10, 2024
3d14329
fix details
martinvuyk Dec 10, 2024
f60c04e
fix details
martinvuyk Dec 10, 2024
5496472
Merge remote-tracking branch 'upstream/main' into fix-iter-ergonomics
martinvuyk Feb 3, 2025
462ce86
fix after merge
martinvuyk Feb 3, 2025
3014876
fix after merge
martinvuyk Feb 3, 2025
dc14095
fix after merge
martinvuyk Feb 3, 2025
df753dc
fix after merge
martinvuyk Feb 3, 2025
0870a2b
fix after merge
martinvuyk Feb 3, 2025
6ea3ff4
fix after merge
martinvuyk Feb 3, 2025
1989e09
fix details
martinvuyk Feb 3, 2025
d0e0601
fix detail
martinvuyk Feb 3, 2025
96c1ba5
Merge remote-tracking branch 'upstream/main' into fix-iter-ergonomics
martinvuyk Feb 28, 2025
f11594a
change _StringSliceIter to CodepointSliceIter
martinvuyk Feb 28, 2025
d17b139
fix detail with origins
martinvuyk Feb 28, 2025
5368b18
fix details
martinvuyk Feb 28, 2025
a5baa36
fix details
martinvuyk Feb 28, 2025
20d9fe2
fix detail
martinvuyk Feb 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stdlib/src/builtin/builtin_list.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ struct _VariadicListIter[type: AnyTrivialRegType]:
fn __len__(self) -> Int:
return len(self.src) - self.index

@always_inline
fn __bool__(self) -> Bool:
return self.__hasmore__()


@register_passable("trivial")
struct VariadicList[type: AnyTrivialRegType](Sized):
Expand Down Expand Up @@ -258,6 +262,10 @@ struct _VariadicListMemIter[
fn __len__(self) -> Int:
return len(self.src[]) - self.index

@always_inline
fn __bool__(self) -> Bool:
return self.__hasmore__()


# Helper to compute the union of two origins:
# TODO: parametric aliases would be nice.
Expand Down
Loading