I am having trouble figuring out what the convert method is supposed to be for a custom struct.
using Parameters
using LeftChildRightSiblingTrees
@with_kw struct DigitalContour
id::Int = 0
is_outer::Bool = false
pixels::Vector{CartesianIndex{2}} = Vector{CartesianIndex{2}}(undef, 0)
end
root = Node(DigitalContour(is_outer = false))
addchild(root, Node(DigitalContour(id = 1)))
ERROR: MethodError: Cannot convert an object of type Node{DigitalContour} to an object of type DigitalContour
Closest candidates are:
convert(::Type{T}, ::T) where T at essentials.jl:168
DigitalContour(::Any, ::Any, ::Any) at /home/zygmunt/.julia/packages/Parameters/l76EM/src/Parameters.jl:478
Stacktrace:
[1] Node{DigitalContour}(::Node{DigitalContour}, ::Node{DigitalContour}) at /home/zygmunt/.julia/packages/LeftChildRightSiblingTrees/7aS8D/src/LeftChildRightSiblingTrees.jl:45
[2] Node(::Node{DigitalContour}, ::Node{DigitalContour}) at /home/zygmunt/.julia/packages/LeftChildRightSiblingTrees/7aS8D/src/LeftChildRightSiblingTrees.jl:52
[3] addchild(::Node{DigitalContour}, ::Node{DigitalContour}) at /home/zygmunt/.julia/packages/LeftChildRightSiblingTrees/7aS8D/src/LeftChildRightSiblingTrees.jl:90
[4] top-level scope at none:0
Part of my problem is that I don't really understand how the call to convert is being called. Thanks for any advice you might have.
I am having trouble figuring out what the
convert
method is supposed to be for a custom struct.Part of my problem is that I don't really understand how the call to
convert
is being called. Thanks for any advice you might have.