Hello everyone
I want to encapsulate a MutableNamedTuple in my own structure, but I always encounter type conversion errors, please help to see, thank you
using MutableNamedTuples
mutable struct TM{N,T}
field1::Int32
field2::String
pm::MutableNamedTuple{N,T}
function TM{N,T}(;kwargs...) where {N,T}
a=MutableNamedTuple{N}(values(kwargs.data)) #Here I have successfully generated the MutableNamedTuple of the specified type
println(dump(a))
this =new()
this.pm=a #Type conversion error here
return this
end
end
TM(;kwargs...) = TM{keys(kwargs.data),typeof(values(kwargs.data))}(;kwargs...)
function test()
g = TM(b = 3,)
#println(dump(g))
return
end
function ttt()
@time test()
#@code_typed test()
end
ttt()