Skip to content

Commit

Permalink
Eliminate legacy serialization structs (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Sep 1, 2020
1 parent bfa3ea8 commit 4f760f6
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/compat.jl
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
# These `deserialize` methods are used to be able to deserialize intervals using the
# structure that was used before Intervals 1.3.

struct _LegacyInterval{T}
first::T
last::T
inclusivity::Inclusivity
end

function Serialization.deserialize(s::AbstractSerializer, ::Type{Interval{T}}) where T
old = deserialize(s, _LegacyInterval{T})
left = deserialize(s)
right = deserialize(s)
inclusivity = deserialize(s)

L = bound_type(first(old.inclusivity))
R = bound_type(last(old.inclusivity))

return Interval{T,L,R}(old.first, old.last)
end
L = bound_type(first(inclusivity))
R = bound_type(last(inclusivity))

struct _LegacyAnchoredInterval{P,T}
anchor::T
inclusivity::Inclusivity
return Interval{T,L,R}(left, right)
end

function Serialization.deserialize(s::AbstractSerializer, ::Type{AnchoredInterval{P,T}}) where {P,T}
old = deserialize(s, _LegacyAnchoredInterval{P,T})
anchor = deserialize(s)
inclusivity = deserialize(s)

L = bound_type(first(old.inclusivity))
R = bound_type(last(old.inclusivity))
L = bound_type(first(inclusivity))
R = bound_type(last(inclusivity))

return AnchoredInterval{P,T,L,R}(old.anchor)
return AnchoredInterval{P,T,L,R}(anchor)
end

# Works around an issue where a `StepRangeLen` tries to convert the step to an
Expand Down

0 comments on commit 4f760f6

Please sign in to comment.