Skip to content

Irrational{S} support missing #48

@patkwee

Description

@patkwee

Serialization of the type Irrational{S} is missing. For example:

julia> pack(pi)
ERROR: no non-`AnyType` MsgPack mapping found for Irrational{}; please overload `msgpack_type` for this type.

I think most users are not aware that pi is not simply the floating point representation of pi, therefore expecting that if you can pack a float, you can also pack pi.

I would propose to add the following to the package:

MsgPack.msgpack_type(::Type{Irrational{S}}) where S = MsgPack.FloatType()
MsgPack.to_msgpack(::MsgPack.FloatType, x::Irrational{S}) where S = float(x)

I could prepare a PR, if you find this useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions