Skip to content

Commit

Permalink
fixes for 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bramtayl committed Nov 30, 2018
1 parent 46fd93b commit 0231927
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/LightQuery.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ include("Nameless.jl")

import Base: diff_names, merge

using InteractiveUtils: @code_warntype

export Name
"""
struct Name{T} end
Expand All @@ -13,10 +15,10 @@ julia> using LightQuery
julia> using Test: @inferred
julia> Name(:a)((a = 1, b = 2.0,))
julia> @inferred Name(:a)((a = 1, b = 2.0,))
1
julia> merge(Name(:a), Name(:b))
julia> @inferred merge(Name(:a), Name(:b))
Names{(:a, :b)}()
```
"""
Expand All @@ -33,16 +35,16 @@ julia> using LightQuery
julia> using Test: @inferred
julia> Names(:a)((a = 1, b = 2.0,))
julia> @inferred Names(:a)((a = 1, b = 2.0,))
(a = 1,)
```
"""
struct Names{T} end
@inline Names(args...) = Names{args}()
(::Names{T})(x) where T = select(x, Names(T...))
(::Names{T})(x) where T = select(x, Names{T}())

@inline inner(n::Name{T}) where T = T
merge(ns::Name...) = Names(inner.(ns)...)
merge(ns::Name...) = Names{inner.(ns)}()

export unname
"""
Expand Down Expand Up @@ -229,6 +231,6 @@ julia> @inferred remove((a = 1, b = 2.0), Names(:b))
```
"""
remove(data, columns::Names{T}) where T =
select(data, Names(diff_names(propertynames(data), T)...))
select(data, Names{diff_names(propertynames(data), T)}())

end

0 comments on commit 0231927

Please sign in to comment.