Skip to content

Commit

Permalink
Fix slicing in 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara committed Oct 31, 2024
1 parent 2643b6c commit 25e6fed
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/vector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1991,11 +1991,21 @@ defmodule Aja.Vector do
{:ok, Raw.member?(internal, value)}
end

def slice(%Aja.Vector{__vector__: internal}) do
size = Aja.Vector.Raw.size(internal)
# TODO remove when dropping support for Elixir 1.12
if Version.compare(System.version(), "1.13.0") != :lt do
def slice(%Aja.Vector{__vector__: internal}) do
size = Aja.Vector.Raw.size(internal)

{:ok, size,
fn start, length, 1 -> Aja.Vector.Raw.slice(internal, start, start + length - 1) end}
{:ok, size,
fn start, length, 1 -> Aja.Vector.Raw.slice(internal, start, start + length - 1) end}
end
else
def slice(%Aja.Vector{__vector__: internal}) do
size = Aja.Vector.Raw.size(internal)

{:ok, size,
fn start, length -> Aja.Vector.Raw.slice(internal, start, start + length - 1) end}
end
end

def reduce(%Aja.Vector{__vector__: internal}, acc, fun) do
Expand Down

0 comments on commit 25e6fed

Please sign in to comment.