Skip to content

Commit 10ef59c

Browse files
committed
Use convert rather than constructor between Matchings
1 parent 580cad9 commit 10ef59c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/graph/bipartite.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ struct Matching{U, V <: AbstractVector} <: AbstractVector{Union{U, Int}} #=> :Un
3535
inv_match::Union{Nothing, V}
3636
end
3737
# These constructors work around https://github.com/JuliaLang/julia/issues/41948
38-
function Matching{V}(m::Matching) where {V}
38+
Matching{V}(m::Matching) where {V} = convert(Matching{V}, m)
39+
function Base.convert(T::Type{<:Matching{V}}, m::Matching) where {V}
3940
eltype(m) === Union{V, Int} && return M
4041
VUT = typeof(similar(m.match, Union{V, Int}))
4142
Matching{V}(convert(VUT, m.match),
4243
m.inv_match === nothing ? nothing : convert(VUT, m.inv_match))
4344
end
45+
4446
Matching(m::Matching) = m
4547
Matching{U}(v::V) where {U, V <: AbstractVector} = Matching{U, V}(v, nothing)
4648
function Matching{U}(v::V, iv::Union{V, Nothing}) where {U, V <: AbstractVector}

0 commit comments

Comments
 (0)