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

Use [x; n] syntax for non-Copy types #1366

Closed
steveklabnik opened this issue Nov 12, 2015 · 5 comments
Closed

Use [x; n] syntax for non-Copy types #1366

steveklabnik opened this issue Nov 12, 2015 · 5 comments
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@steveklabnik
Copy link
Member

Originally at rust-lang/rust#5244

@Gankra
Copy link
Contributor

Gankra commented Nov 13, 2015

The title of this issue implies making this work for all arbitrary non-Copy types. Is clone a lang item yet? If not, this would necessitate that. Unless the desugar is to textually duplicate x and evaluate it n times, but that would be contrary to how vec! desugars.

However the original issue referenced was just about making enum variants that only contain Copy data behaving as Copy types for the purposes of array literals. The canonical example being None, which is always producable, no matter what type the Option wraps.

@Kimundi
Copy link
Member

Kimundi commented Nov 13, 2015

I think the intention was "make the [x; n] syntax accept either Copyable types or constexprs".

This would never run user code, but still enable the usecase of, for example, initializing a array of Options to non-copyable data.

(static X: Option<Box<u32>> = None; compiles today for the same reasoning)

@ticki
Copy link
Contributor

ticki commented Nov 16, 2015

Big 👍 here. I've needed this many times.

@ticki
Copy link
Contributor

ticki commented Nov 22, 2015

Dup of #1109?

@steveklabnik
Copy link
Member Author

yes, it is.

@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the RFC. label Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

5 participants