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

Immutable data deserialization support #1190

Merged
merged 1 commit into from
Jul 31, 2015
Merged

Immutable data deserialization support #1190

merged 1 commit into from
Jul 31, 2015

Conversation

japplegame
Copy link
Contributor

Adds the ability to deserialize immutable data. See unittest.

@@ -446,8 +446,12 @@ private void serializeImpl(Serializer, alias Policy, T, ATTRIBUTES...)(ref Seria
} else static assert(false, "Unsupported serialization type: " ~ T.stringof);
}

private T deserializeImpl(T, alias Policy, Serializer, ATTRIBUTES...)(ref Serializer deserializer) if(!isMutable!T)
{
return cast(T) deserializeImpl!(Unqual!T, Policy, Serializer, ATTRIBUTES)(deserializer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use assumeUnique here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case assumeUnique will not help, because it works only with arrays.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wut. I always assumed it worked with everything and was just documenting.
I'm not familiar with this part, but could you also add an unittest for a const/immutable object if there's not one already ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I slightly modified the unittest.

Adds the ability to deserialize immutable data. See unittest.
s-ludwig added a commit that referenced this pull request Jul 31, 2015
Immutable data deserialization support
@s-ludwig s-ludwig merged commit 4929211 into vibe-d:master Jul 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants