Skip to content

Commit 259a887

Browse files
authored
Support for empty NamedTuple in flatten (#22)
* Support for empty NamedTuples in flatten * Update runtests.jl * Fixed missing bracket in runtests.jl * bump version
1 parent 5e64c39 commit 259a887

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NestedTuples"
22
uuid = "a734d2a7-8d68-409b-9419-626914d4061d"
33
authors = ["Chad Scherrer <chad.scherrer@gmail.com> and contributors"]
4-
version = "0.3.11"
4+
version = "0.3.12"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/leaves.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ flatten(x, y...) = (flatten(x)..., flatten(y...)...)
2323
flatten(x::Tuple) = flatten(x...)
2424
flatten(x::NamedTuple) = flatten(values(x)...)
2525
flatten(x) = (x,)
26+
flatten() = ()
2627

2728

2829
using GeneralizedGenerated

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ using NestedTuples: with, TypelevelExpr
99
@test NestedTuples.exprify(x; rename=false) == ([:a, :b, :l, :u], :((a = (a = a, b = b), q = (l = l, u = u))))
1010

1111
@test NestedTuples.flatten(x) == (:a, :b, :l, :u)
12+
13+
@test NestedTuples.flatten( (a = 1, b = (;), c = 2) ) == (1, 2)
1214

1315
@test NestedTuples.keysort(x) == (a = (a = :a, b = :b), q = (l = :l, u = :u))
1416

0 commit comments

Comments
 (0)