Skip to content

Commit efa17fc

Browse files
remove keypath indexing
1 parent 6ace8de commit efa17fc

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

src/functor.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ function makefunctor(m::Module, T, fs = fieldnames(T))
3737
reconstruct(y::NamedTuple) = $T($(escargs_nt...))
3838
return (;$(escfs...)), reconstruct
3939
end
40-
41-
Base.getindex(x::$T, kp::KeyPath) = getkeypath(x, kp)
4240
end
4341
end
4442

src/keypath.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ _haskey(x, k::AbstractString) = haskey(x, k)
6868
6969
Return the value in `x` at the path `kp`.
7070
71-
For object types on which `@functor` has been applied, `x[kp]` is equivalent to `getkeypath(x, kp)`.
72-
7371
See also [`haskeypath`](@ref).
7472
7573
# Examples

test/keypath.jl

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,14 @@
2222
@test getkeypath(x, KeyPath(:b, :c)) == 4
2323
@test getkeypath(x, KeyPath(:b, "d", 2)) == 6
2424

25-
@testset "@functor defines keypath indexing" begin
26-
struct Tkp
27-
a
28-
b
29-
c
30-
end
31-
@functor Tkp
32-
33-
x = Tkp(3, Tkp(4, 5, 6), (7, 8))
34-
kp = KeyPath(:b, :b, 1)
35-
@test x[kp] == getkeypath(x, kp)
36-
@test x[KeyPath(:c, :2)] == 8
25+
struct Tkp
26+
a
27+
b
28+
c
3729
end
30+
x = Tkp(3, Tkp(4, 5, (6, 7)), 8)
31+
kp = KeyPath(:b, :c, 2)
32+
@test getkeypath(x, kp) == 7
3833
end
3934

4035
@testset "haskeypath" begin

0 commit comments

Comments
 (0)