Skip to content

Commit

Permalink
Merge pull request #73 from mauro3/m3/contains_deprecation
Browse files Browse the repository at this point in the history
Deprecation contains -> occursin
  • Loading branch information
MikeInnes authored May 29, 2018
2 parents dc43c63 + 8ebe71a commit 56d5030
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.6
Compat 0.54
Compat 0.62
4 changes: 2 additions & 2 deletions src/match.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function store!(env, name, ex)
end

isbinding(s) = false
isbinding(s::Symbol) = contains(string(s), r"[^_]_(_str)?$")
isbinding(s::Symbol) = occursin(r"[^_]_(_str)?$", string(s))

function bname(s::Symbol)
Symbol(Base.match(r"^@?(.*?)_+(_str)?$", string(s)).captures[1])
Expand All @@ -26,7 +26,7 @@ match_inner(pat::QuoteNode, ex::QuoteNode, env) =
match(pat.value, ex.value, env)

isslurp(s) = false
isslurp(s::Symbol) = s == :__ || contains(string(s), r"[^_]__$")
isslurp(s::Symbol) = s == :__ || occursin(r"[^_]__$", string(s))

function slurprange(pat)
slurps = length(filter(isslurp, pat))
Expand Down
4 changes: 3 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ struct TypeBind
end

istb(s) = false
istb(s::Symbol) = !(endswith(string(s), "_") || endswith(string(s), "_str")) && contains(string(s), "_")
istb(s::Symbol) = !(endswith(string(s), "_") ||
endswith(string(s), "_str")) &&
occursin("_", string(s))

tbname(s::Symbol) = Symbol(split(string(s), "_")[1])
tbname(s::TypeBind) = s.name
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function inexpr(ex, x)
return result
end

isgensym(s::Symbol) = contains(string(s), "#")
isgensym(s::Symbol) = occursin("#", string(s))
isgensym(s) = false

function gensymname(x::Symbol)
Expand Down

0 comments on commit 56d5030

Please sign in to comment.