@@ -133,12 +133,6 @@ function NamedTuple{names, T}(nt::NamedTuple) where {names, T <: Tuple}
133
133
end
134
134
end
135
135
136
- # Like NamedTuple{names, T} as a constructor, but omits the additional
137
- # `convert` call, when the types are known to match the fields
138
- @eval function _new_NamedTuple (T:: Type{NamedTuple{NTN, NTT}} where {NTN, NTT}, args:: Tuple )
139
- $ (Expr (:splatnew , :T , :args ))
140
- end
141
-
142
136
function NamedTuple {names} (nt:: NamedTuple ) where {names}
143
137
if @generated
144
138
idx = Int[ fieldindex (nt, names[n]) for n in 1 : length (names) ]
@@ -161,6 +155,12 @@ NamedTuple{names, Union{}}(itr::Tuple) where {names} = throw(MethodError(NamedTu
161
155
162
156
end # if Base
163
157
158
+ # Like NamedTuple{names, T} as a constructor, but omits the additional
159
+ # `convert` call, when the types are known to match the fields
160
+ @eval function _new_NamedTuple (T:: Type{NamedTuple{NTN, NTT}} where {NTN, NTT}, args:: Tuple )
161
+ $ (Expr (:splatnew , :T , :args ))
162
+ end
163
+
164
164
length (t:: NamedTuple ) = nfields (t)
165
165
iterate (t:: NamedTuple , iter= 1 ) = iter > nfields (t) ? nothing : (getfield (t, iter), iter + 1 )
166
166
rest (t:: NamedTuple ) = t
0 commit comments