Skip to content

Commit

Permalink
Merge pull request JuliaLang#21789 from musm/patch-1
Browse files Browse the repository at this point in the history
Use where syntax in Enums.jl
  • Loading branch information
Sacha0 authored May 12, 2017
2 parents 45285a7 + b0a2831 commit 7d7989f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/Enums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function basetype end

abstract type Enum{T<:Integer} end

Base.convert{T<:Integer}(::Type{Integer}, x::Enum{T}) = bitcast(T, x)
Base.convert{T<:Integer,T2<:Integer}(::Type{T}, x::Enum{T2}) = convert(T, bitcast(T2, x))
Base.write{T<:Integer}(io::IO, x::Enum{T}) = write(io, T(x))
Base.read{T<:Enum}(io::IO, ::Type{T}) = T(read(io, Enums.basetype(T)))
Base.convert(::Type{Integer}, x::Enum{T}) where {T<:Integer} = bitcast(T, x)
Base.convert(::Type{T}, x::Enum{T2}) where {T<:Integer,T2<:Integer} = convert(T, bitcast(T2, x))
Base.write(io::IO, x::Enum{T}) where {T<:Integer} = write(io, T(x))
Base.read(io::IO, ::Type{T}) where {T<:Enum} = T(read(io, Enums.basetype(T)))

# generate code to test whether expr is in the given set of values
function membershiptest(expr, values)
Expand Down

0 comments on commit 7d7989f

Please sign in to comment.