Skip to content

Commit

Permalink
use name output for list iter __next__()
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Grenier <[email protected]>
  • Loading branch information
bgreni committed Jan 14, 2025
1 parent ab8734f commit 29d992f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions stdlib/src/collections/list.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ struct _ListIter[
fn __iter__(self) -> Self:
return self

fn __next__(
mut self,
) -> Pointer[T, list_origin]:
fn __next__(mut self, out p: Pointer[T, list_origin]):
@parameter
if forward:
p = Pointer.address_of(self.src[][self.index])
self.index += 1
return Pointer.address_of(self.src[][self.index - 1])
else:
self.index -= 1
return Pointer.address_of(self.src[][self.index])
p = Pointer.address_of(self.src[][self.index])

@always_inline
fn __has_next__(self) -> Bool:
Expand Down

0 comments on commit 29d992f

Please sign in to comment.