Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define StructType for Some as CustomStruct #45

Merged
merged 2 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/StructTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ function lowertype end

lowertype(::Type{T}) where {T} = Any

StructType(::Type{Some{T}}) where {T} = CustomStruct()
lower(x::Some) = x.value
lowertype(::Type{Some{T}}) where {T} = T

"A kind of `StructType` where an object's \"data\" is made up, at least in part, by its direct fields. When serializing, appropriate fields will be accessed directly."
abstract type DataType <: StructType end

Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ x = "499beb72-22ea-11ea-3366-55749430b981"
v = v"1.2.3"
@test StructTypes.StructType(v) == StructTypes.StringType()

# Some wrapper
@test StructTypes.StructType(Some(1)) == StructTypes.CustomStruct()

end

struct B
Expand Down