Skip to content

Commit

Permalink
fix: scaladoc description
Browse files Browse the repository at this point in the history
As mentioned in #27.
  • Loading branch information
geminicaprograms committed Oct 30, 2023
1 parent 2e35400 commit 856823e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions core/src/main/scala/ox/channels/SourceOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,13 @@ trait SourceOps[+T] { this: Source[T] =>
}
c

/** Returns the first element from this source wrapped in [[Some]] or [[None]] when the source is empty. Note that `headOption` is not an
/** Returns the first element from this source wrapped in [[Some]] or [[None]] when this source is empty. Note that `headOption` is not an
* idempotent operation on source as it receives elements from it.
*
* @return
* A `Some(first element)` if source is not empty or `None` otherwise.
* @throws ChannelClosedException.Error
* When [[receive]] fails.
* When receiving an element from this source fails.
* @example
* {{{
* import ox.*
Expand All @@ -542,30 +542,30 @@ trait SourceOps[+T] { this: Source[T] =>
case t: T @unchecked => Some(t)
}

/** Returns the first element from this source or throws [[NoSuchElementException]] when the source is empty. In case when the [[receive]]
* operation fails with exception then [[ChannelClosedException.Error]] is thrown. Note that `head` is not an idempotent operation on
/** Returns the first element from this source or throws [[NoSuchElementException]] when this source is empty. In case when receiving an
* element fails with exception then [[ChannelClosedException.Error]] is thrown. Note that `head` is not an idempotent operation on
* source as it receives elements from it.
*
* @return
* A first element if source is not empty or throws otherwise.
* @throws NoSuchElementException
* When a source is empty.
* @throws ChannelClosedException.Error
* When [[receive]] fails.
* When receiving an element from this source fails.
* @example
* {{{
* import ox.*
* import ox.channels.Source
*
* supervised {
* Source.empty[Int].head() // throws NoSuchElementException("cannot obtain head from an empty source")
* Source.empty[Int].head() // throws NoSuchElementException("cannot obtain head element from an empty source")
* val s = Source.fromValues(1, 2)
* s.head() // 1
* s.head() // 2
* }
* }}}
*/
def head(): T = headOption().getOrElse(throw new NoSuchElementException("cannot obtain head from an empty source"))
def head(): T = headOption().getOrElse(throw new NoSuchElementException("cannot obtain head element from an empty source"))

/** Sends elements to the returned channel limiting the throughput to specific number of elements (evenly spaced) per time unit. Note that
* the element's `receive()` time is included in the resulting throughput. For instance having `throttle(1, 1.second)` and `receive()`
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/ox/channels/SourceOpsHeadTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SourceOpsHeadTest extends AnyFlatSpec with Matchers {
it should "throw NoSuchElementException for the empty source" in supervised {
the[NoSuchElementException] thrownBy {
Source.empty[Int].head()
} should have message "cannot obtain head from an empty source"
} should have message "cannot obtain head element from an empty source"
}

it should "throw ChannelClosedException.Error with exception and message that was thrown during retrieval" in supervised {
Expand Down

0 comments on commit 856823e

Please sign in to comment.