common: shorten some comments

It's important to show the panic cases on the first doc line.
Makes it easier to notice in grep, etc.
This commit is contained in:
Felix Lange 2025-03-17 15:32:13 +01:00
parent 8c3091edc1
commit c9610fbf57

View file

@ -35,8 +35,7 @@ func (r Range[T]) First() T {
return r.first return r.first
} }
// Last returns the last element of the range. The function panics if the range // Last returns the last element of the range. This panics for empty ranges.
// is empty.
func (r Range[T]) Last() T { func (r Range[T]) Last() T {
if r.first == r.afterLast { if r.first == r.afterLast {
panic("last item of zero length range is not allowed") panic("last item of zero length range is not allowed")
@ -96,8 +95,7 @@ func (r Range[T]) Intersection(q Range[T]) Range[T] {
return i return i
} }
// Union returns the union of two ranges. The function panics if there is a gap // Union returns the union of two ranges. Panics for gapped ranges.
// between the ranges.
func (r Range[T]) Union(q Range[T]) Range[T] { func (r Range[T]) Union(q Range[T]) Range[T] {
if max(r.first, q.first) > min(r.afterLast, q.afterLast) { if max(r.first, q.first) > min(r.afterLast, q.afterLast) {
panic("cannot create union; gap between ranges") panic("cannot create union; gap between ranges")