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

Default #19

Merged
merged 3 commits into from
Dec 21, 2015
Merged

Default #19

merged 3 commits into from
Dec 21, 2015

Conversation

dbrgn
Copy link
Collaborator

@dbrgn dbrgn commented Dec 4, 2015

Implement Default for Optional as discussed in #6.

@dbrgn
Copy link
Collaborator Author

dbrgn commented Dec 4, 2015

I could swear there was once an issue without the namespacing

That was before @dns2utf8 added the use Optional::* line :)

@rnestler
Copy link
Member

rnestler commented Dec 4, 2015

Removed unneeded namespacing

Can you see it 😉

@rnestler
Copy link
Member

rnestler commented Dec 4, 2015

Maybe derive it for all spaceapi types as well? Otherwise there is little use for it.

@dbrgn
Copy link
Collaborator Author

dbrgn commented Dec 4, 2015

Maybe derive it for all spaceapi types as well? Otherwise there is little use for it.

Default for location:

pub struct Location {
    address: Absent,
    lat: 0.0,
    lon: 0.0,
}

The 0.0 doesn't look useful to me. A latitude or longitude does not have a good default.

@rnestler
Copy link
Member

rnestler commented Dec 4, 2015

Yeah but for some of the types it may be useful.

@dbrgn
Copy link
Collaborator Author

dbrgn commented Dec 4, 2015

Alright, but we can only implement it for leaf types, not for types that contain other types that don't implement Default.

@dns2utf8
Copy link
Contributor

dns2utf8 commented Dec 4, 2015

0.0 / 0.0 is a common default for long / lat, looks ok to me

@dbrgn
Copy link
Collaborator Author

dbrgn commented Dec 4, 2015

0.0 / 0.0 is a common default for long / lat, looks ok to me

But does it make sense semantically? That location is somewhere in the Gulf of Guinea in the Atlantic Ocean. Does it make sense to default a location to the Gulf of Guinea? I think not.

@rnestler
Copy link
Member

rnestler commented Dec 4, 2015

You could default it to NaN...

@dns2utf8
Copy link
Contributor

dns2utf8 commented Dec 4, 2015

good point

@dbrgn
Copy link
Collaborator Author

dbrgn commented Dec 4, 2015

We can't override Default for f64. And NaN is not a good default either. A location does not have a good default. NaN would correspond with "no location", which is not valid according to the SpaceAPI. Otherwise we could use an Option.

@dbrgn dbrgn force-pushed the default branch 2 times, most recently from 11a98ea to fc9da2a Compare December 5, 2015 21:54
@rnestler
Copy link
Member

However, I think the Default implementation for Optional is OK like that.

dbrgn added a commit that referenced this pull request Dec 21, 2015
@dbrgn dbrgn merged commit 5ab8db5 into master Dec 21, 2015
@dbrgn dbrgn deleted the default branch December 21, 2015 12:18
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