Skip to content

Commit

Permalink
Add docs for Option's iterator methods
Browse files Browse the repository at this point in the history
  • Loading branch information
danakj committed Dec 12, 2023
1 parent 728771a commit 302be80
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sus/option/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -1680,19 +1680,30 @@ class Option final {
return ::sus::clone(*this).as_mut();
}

/// Produces an [`Iterator`]($sus::iter::Iterator) over the single item in the
/// `Option`, or an empty iterator. The iterator will return a const
/// reference.
_sus_pure constexpr OptionIter<const std::remove_reference_t<T>&> iter()
const& noexcept;
constexpr OptionIter<const std::remove_reference_t<T>&> iter() && noexcept
requires(std::is_reference_v<T>);
constexpr OptionIter<const std::remove_reference_t<T>&> iter() const& noexcept
requires(std::is_reference_v<T>);

/// Produces an [`Iterator`]($sus::iter::Iterator) over the single item in the
/// `Option`, or an empty iterator. If the `Option` holds a value, the
/// iterator will return a mutable reference to it. If the `Option` holds a
/// reference, it will return that reference.
_sus_pure constexpr OptionIter<T&> iter_mut() & noexcept;
constexpr OptionIter<T&> iter_mut() && noexcept
requires(std::is_reference_v<T>);
constexpr OptionIter<T&> iter_mut() const& noexcept
requires(std::is_reference_v<T>);

/// Produces an [`Iterator`]($sus::iter::Iterator) over the single item in the
/// `Option`, or an empty iterator. If the Option holds a value, the iterator
/// will return ownership of the value. If the `Option` holds a reference, it
/// will return that reference.
constexpr OptionIter<T> into_iter() && noexcept;
constexpr OptionIter<T> into_iter() const& noexcept
requires(::sus::mem::CopyOrRef<T>);
Expand Down

0 comments on commit 302be80

Please sign in to comment.