Skip to content

Implement Default for owned arrays #213

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

Merged
merged 2 commits into from
Aug 19, 2016
Merged

Implement Default for owned arrays #213

merged 2 commits into from
Aug 19, 2016

Conversation

bluss
Copy link
Member

@bluss bluss commented Aug 14, 2016

zero-dimensional arrays (using () or Vec::new() as the dimension/D type
parameter) will have 1 element in the default state.

nonzero-dimensional arrays (using Ix, (Ix, Ix) and so on) will have
0 elements in their default state.

Fixes #204

@bluss
Copy link
Member Author

bluss commented Aug 14, 2016

ok @SuperFluffy, the reality of zero-dimensional arrays say that these semantics are needed for at least some arrays.

Is it too insane to start with either 1 or 0 elements depending on the D parameter? We could make all arrays have exactly one element too, but then we need to allocate a vector in the common case.

bluss added 2 commits August 14, 2016 20:11
zero-dimensional arrays (using () or Vec::new() as the dimension/D type
parameter) will have 1 element in the default state.

nonzero-dimensional arrays (using Ix, (Ix, Ix) and so on) will have
0 elements in their default state.
@SuperFluffy
Copy link
Contributor

I think your solution is a good one. Even though I'd prefer to have the 0-dimensional case to have 0 elements as well, though that's obviously not going to work. I am strongly opposed to the other arrays having a default element... I can't articulate why that is, but I'd rather have the 0-d case be a special one.

@bluss bluss merged commit 295208a into master Aug 19, 2016
@bluss bluss deleted the default branch August 19, 2016 16:28
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.

2 participants