410410
411411Return the first element of `v` and all other elements as a new memory view.
412412
413- This function will throw a `BoundsError ` if `v` is empty.
413+ This function will throw a `LightBoundsError ` if `v` is empty.
414414
415415See also: [`split_last`](@ref)
416416
@@ -425,7 +425,7 @@ julia> split_first(v[1:1])
425425(0x01, UInt8[])
426426
427427julia> split_first(v[1:0])
428- ERROR: BoundsError: attempt to access 0-element MutableMemoryView{UInt8} at index [1]
428+ ERROR: LightBoundsErrors.LightBoundsError: out-of-bounds indexing: `collection [1]`, where:
429429[...]
430430```
431431"""
439439
440440Return the last element of `v` and all other elements as a new memory view.
441441
442- This function will throw a `BoundsError ` if `v` is empty.
442+ This function will throw a `LightBoundsError ` if `v` is empty.
443443
444444See also: [`split_first`](@ref)
445445
@@ -454,7 +454,7 @@ julia> split_last(v[1:1])
454454(0x01, UInt8[])
455455
456456julia> split_last(v[1:0])
457- ERROR: BoundsError: attempt to access 0-element MutableMemoryView{UInt8} at index [1]
457+ ERROR: LightBoundsErrors.LightBoundsError: out-of-bounds indexing: `collection [1]`, where:
458458[...]
459459```
460460"""
@@ -469,10 +469,10 @@ end
469469Split a memory view into two at an index.
470470
471471The first will contain all indices in `1:i-1`, the second `i:end`.
472- This function will throw a `BoundsError ` if `i` is not in `1:end+1`.
472+ This function will throw a `LightBoundsError ` if `i` is not in `1:end+1`.
473473
474474# Examples
475- ```jldocstest
475+ ```jldoctest
476476julia> split_at(MemoryView([1,2,3,4,5]), 2)
477477([1], [2, 3, 4, 5])
478478
@@ -481,7 +481,9 @@ julia> split_at(MemoryView(Int8[1, 2, 3]), 4)
481481```
482482"""
483483function split_at (v:: MemoryView , i:: Int )
484- @boundscheck checkbounds (1 : (lastindex (v) + 1 ), i)
484+ @boundscheck if i ∉ 1 : (lastindex (v) + 1 )
485+ throw_lightboundserror (v, i)
486+ end
485487 return (@inbounds (truncate (v, i - 1 )), @inbounds (truncate_start (v, i)))
486488end
487489
0 commit comments