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

Edition 2021 blog post #825

Merged
merged 6 commits into from
May 11, 2021
Merged

Edition 2021 blog post #825

merged 6 commits into from
May 11, 2021

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Apr 28, 2021

cc @rust-lang/project-edition-2021

Rendered

Closes rust-lang/rust#84593

@m-ou-se m-ou-se requested a review from a team as a code owner April 28, 2021 10:16
@ChrisDenton
Copy link
Member

In the panic section, should panic_any be briefly mentioned as an alternative for rarer use cases?

@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 28, 2021

In the panic section, should panic_any be briefly mentioned as an alternative for rarer use cases?

I don't think so. This is not the edition guide; just an overview. I only very quickly mention the existence of non-string panics, which are rather uncommon.

Edit: Added a small note now.

@therealprof
Copy link
Contributor

Hm, I'm seeing a contradiction in the text:

for e in [1, 2, 3] {} // Error :(

and later it says:

It does not affect any other syntax such as for e in [1, 2, 3] or iter.zip([1, 2, 3]). Those will start to work in all editions.

Did you mean to say for e in &[1, 2, 3]?

Also I find it strange that for &e in &[1, 2, 3] {} // Ok :) is mentioned since I don't see that &esyntax too often and it might throw off some readers...

@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 28, 2021

@therealprof That snippet describes the current situation, before Rust 1.53.

Until Rust 1.53, [..]

Starting in 1.53, we will have that trait implementation and for e in [1, 2, 3] {} will start to work in all editions.

[..] Those will start to work in all editions.

@therealprof
Copy link
Contributor

@m-ou-se Thanks for pointing out how bad of a reader I am. 😅 After a few more passes I can parse that correctly, so 👍 from me. I'd still change

for &e in &[1, 2, 3] {}

to

for e in &[1, 2, 3] {}

so the important difference stands out a bit clearer.

@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 28, 2021

I purposely put that & there, to make it clear that iterating over &[1, 2, 3] results in &i32, not i32. Otherwise the difference might just seem like you can now write in [..] instead of in &[..] with no semantic difference.

@m-ou-se m-ou-se force-pushed the plan-2021 branch 2 times, most recently from ddf701b to 824cb36 Compare April 28, 2021 13:56
@therealprof
Copy link
Contributor

I purposely put that & there, to make it clear that iterating over &[1, 2, 3] results in &i32, not i32. Otherwise the difference might just seem like you can now write in [..] instead of in &[..] with no semantic difference.

Fair enough, what about ref e then to make it more expressive?

@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 28, 2021

Fair enough, what about ref e then to make it more expressive?

That does the opposite. That will add a reference, giving you &&i32:

    for ref e in &[1, 2, 3] {
        let _: i32 = **e;
    }

@therealprof
Copy link
Contributor

I guess I really need to shut up and hide in a dark place now to read up on the syntax quirks and automatic derefencing. 😅 Thanks for the education.

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

I think pushing this out to May 10th or 11th would be good. By then I hope that we can have the primary edition RFC merged and the changes still in-flight (e.g., T-libs approval of prelude, token reservation RFC merged) also finished up.

posts/2021-04-30-edition-2021.md Outdated Show resolved Hide resolved
posts/2021-04-30-edition-2021.md Outdated Show resolved Hide resolved
posts/2021-04-30-edition-2021.md Outdated Show resolved Hide resolved
posts/2021-04-30-edition-2021.md Outdated Show resolved Hide resolved
@m-ou-se m-ou-se force-pushed the plan-2021 branch 2 times, most recently from 3b31e80 to 2d07263 Compare April 28, 2021 17:53
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
@steffahn
Copy link
Member

steffahn commented May 2, 2021

When reading rust-lang/rust#84147, I found it noteworthy that in particular IntoIterator::into_iter([1, 2, 3]) will work in Rust 2018/2015, too. Maybe that could be mentioned as another example around

syntax such as for e in [1, 2, 3] or iter.zip([1, 2, 3]). Those will start to work in all editions.

@m-ou-se
Copy link
Member Author

m-ou-se commented May 3, 2021

@bstrie, @steffahn, @digama0: Thanks for the feedback.

@m-ou-se
Copy link
Member Author

m-ou-se commented May 3, 2021

I think pushing this out to May 10th or 11th would be good. By then I hope that we can have the primary edition RFC merged and the changes still in-flight (e.g., T-libs approval of prelude, token reservation RFC merged) also finished up.

Sounds good. @rust-lang/core can y'all review it this week so we can publish it next Monday?

@m-ou-se
Copy link
Member Author

m-ou-se commented May 10, 2021

@Mark-Simulacrum Can we get this merged and published today? :)

@Mark-Simulacrum
Copy link
Member

I think let's go for tomorrow: it seems likely this wants good coverage, but today we're merging #836 and that'll likely distract from this.

@m-ou-se
Copy link
Member Author

m-ou-se commented May 11, 2021

tomorrow

$ date +%F
2021-05-11

:D

@Mark-Simulacrum Mark-Simulacrum merged commit e689ed2 into rust-lang:master May 11, 2021
@m-ou-se m-ou-se deleted the plan-2021 branch May 11, 2021 15:10
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.

Blog post announcing Rust 2021 feature set
8 participants