Skip to content

Commit

Permalink
feat!: Option#iter(): array -> Option#iter(): iterable (#21)
Browse files Browse the repository at this point in the history
semantically more correct
  • Loading branch information
Lctrs authored May 7, 2024
1 parent 8cce003 commit 4bfdd07
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ abstract public function okOrElse(callable $err): Result;
* Returns an iterator over the possibly contained value.
* The iterator yields one value if the result is Some, otherwise none.
*
* @return list<T>
* @return iterable<int, T>
*/
abstract public function iter(): array;
abstract public function iter(): iterable;

/**
* Returns None if the option is None, otherwise returns optb.
Expand Down
2 changes: 1 addition & 1 deletion src/Option/None.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function okOrElse(callable $err): Result
return new Err($err(...$this->pass), ...$this->pass);
}

public function iter(): array
public function iter(): iterable
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Option/Some.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function okOrElse(callable $err): Result
return new Ok($this->value, ...$this->pass);
}

public function iter(): array
public function iter(): iterable
{
return [$this->value];
}
Expand Down

0 comments on commit 4bfdd07

Please sign in to comment.