Skip to content

Commit

Permalink
Avoid deprecated negative slice in Elixir v1.16-dev (#128)
Browse files Browse the repository at this point in the history
There is still a long time for Elixir v1.16
but since I run on the edge, I thought I
would send a PR.

Another solution for the problem is to
use `String.slice(string, ignore..-1//1)`
but that would require Elixir v1.12. The
version in this PR supports earlier
versions too.
  • Loading branch information
josevalim authored Jun 4, 2023
1 parent a13e8b8 commit 9bbf43c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/earmark_parser/helpers/string_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ defmodule EarmarkParser.Helpers.StringHelpers do
Remove the leading part of a string
"""
def behead(str, ignore) when is_integer(ignore) do
String.slice(str, ignore..-1)
{_pre, post} = String.split_at(str, ignore)
post
end

def behead(str, leading_string) do
Expand Down

0 comments on commit 9bbf43c

Please sign in to comment.