From 25e6fed5dbaaf5e66c6e1a27a4d8620a8540e4ec Mon Sep 17 00:00:00 2001 From: sabiwara Date: Thu, 31 Oct 2024 10:43:07 +0900 Subject: [PATCH] Fix slicing in 1.12 --- lib/vector.ex | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/vector.ex b/lib/vector.ex index 757542d..fc523fb 100644 --- a/lib/vector.ex +++ b/lib/vector.ex @@ -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