8000 Merge pull request #370 from rust-lang/1.33-announcement · Amndeep7/blog.rust-lang.org@e21211a · GitHub
[go: up one dir, main page]

Skip to content

Commit e21211a

Browse files
Merge pull request rust-lang#370 from rust-lang/1.33-announcement
First draft of 1.33 announcement
2 parents 6c179c2 + 5b4fe13 commit e21211a

File tree

1 file changed

+173
-0
lines changed

1 file changed

+173
-0
lines changed

posts/2019-02-28-Rust-1.33.0.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
layout: post
3+
title: "Announcing Rust 1.33.0"
4+
author: The Rust Release Team
5+
release: true
6+
---
7+
8+
The Rust team is happy to announce a new version of Rust, 1.33.0. Rust is a
9+
programming language that is empowering everyone to build reliable and
10+
efficient software.
11+
12+
If you have a previous version of Rust installed via rustup, getting Rust
13+
1.33.0 is as easy as:
14+
15+
```console
16+
$ rustup update stable
17+
```
18+
19+
If you don't have it already, you can [get `rustup`][install] from the
20+
appropriate page on our website, and check out the [detailed release notes for
21+
1.33.0][notes] on GitHub.
22+
23+
[install]: https://www.rust-lang.org/install.html
24+
[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1330-2019-02-28
25+
26+
## What's in 1.33.0 stable
27+
28+
The two largest features in this release are significant improvements to
29+
`const fn`s, and the stabilization of a new concept: "pinning."
30+
31+
### `const fn` improvements
32+
33+
With `const fn`, you can [now do way more
34+
things!](https://github.com/rust-lang/rust/pull/57175/) Specifically:
35+
36+
* irrefutable destructuring patterns (e.g. `const fn foo((x, y): (u8, u8)) { ... }`)
37+
* `let` bindings (e.g. `let x = 1;`)
38+
* mutable `let` bindings (e.g. `let mut x = 1;`)
39+
* assignment (e.g. `x = y`) and assignment operator (e.g. `x += y`)
40+
expressions, even where the assignment target is a projection (e.g. a struct
41+
field or index operation like `x[3] = 42`)
42+
* expression statements (e.g. `3;`)
43+
44+
You're also [able to call `const unsafe fn`s inside a `const
45+
fn`](https://github.com/rust-lang/rust/pull/57067/), like this:
46+
47+
```rust
48+
const unsafe fn foo() -> i32 { 5 }
49+
const fn bar() -> i32 {
50+
unsafe { foo() }
51+
}
52+
```
53+
54+
With these additions, many more functions in the standard library are able to
55+
be marked as `const`. We'll enumerate those in the library section below.
56+
57+
### Pinning
58+
59+
This release introduces a new concept for Rust programs, implemented as two
60+
types: the [`std::pin::Pin<P>`
61+
type](https://doc.rust-lang.org/std/pin/struct.Pin.html), and the [`Unpin`
62+
marker trait](https://doc.rust-lang.org/std/marker/trait.Unpin.html). The core
63+
idea is elaborated on in [the docs for
64+
`std::pin`](https://doc.rust-lang.org/std/pin/index.html):
65+
66+
> It is sometimes useful to have objects that are guaranteed to not move, in
67+
> the sense that their placement in memory does not change, and can thus be
68+
> relied upon. A prime example of such a scenario would be building
69+
> self-referential structs, since moving an object with pointers to itself will
70+
> invalidate them, which could cause undefined behavior.
71+
>
72+
> A `Pin<P>` ensures that the pointee of any pointer type `P` has a stable location
73+
> in memory, meaning it cannot be moved elsewhere and its memory cannot be
74+
> deallocated until it gets dropped. We say that the pointee is "pinned".
75+
76+
This feature will largely be used by library authors, and so we won't talk a
77+
lot more about the details here. Consult the docs if you're interested in
78+
digging into the details. However, the stabilization of this API is important
79+
to Rust users generally because it is a significant step forward towards a
80+
highly anticipated Rust feature: `async`/`await`. We're not quite there yet,
81+
but this stabilization brings us one step closer. You can track all of the
82+
necessary features at [areweasyncyet.rs](https://areweasyncyet.rs/).
83+
84+
### Import as `_`
85+
86+
[You can now import an item as
87+
`_`](https://github.com/rust-lang/rust/pull/56303/). This allows you to
88+
import a trait's impls, and not have the name in the namespace. e.g.
89+
90+
```rust
91+
use std::io::Read as _;
92+
93+
// Allowed as there is only one `Read` in the module.
94+
pub trait Read {}
95+
```
96+
97+
See the [detailed release notes][notes] for more details.
98+
99+
### Library stabilizations
100+
101+
Here's all of the stuff that's been made `const`:
102+
103+
- [The methods `overflowing_{add, sub, mul, shl, shr}` are now `const`
104+
functions for all numeric types.][57566]
105+
- [The methods `rotate_left`, `rotate_right`, and `wrapping_{add, sub, mul, shl, shr}`
106+
are now `const` functions for all numeric types.][57105]
107+
- [The methods `is_positive` and `is_negative` are now `const` functions for
108+
all signed numeric types.][57105]
109+
- [The `get` method for all `NonZero` types is now `const`.][57167]
110+
- [The methods `count_ones`, `count_zeros`, `leading_zeros`, `trailing_zeros`,
111+
`swap_bytes`, `from_be`, `from_le`, `to_be`, `to_le` are now `const` for all
112+
numeric types.][57234]
113+
- [`Ipv4Addr::new` is now a `const` function][57234]
114+
115+
[57566]: https://github.com/rust-lang/rust/pull/57566
116+
[57105]: https://github.com/rust-lang/rust/pull/57105
117+
[57105]: https://github.com/rust-lang/rust/pull/57105
118+
[57167]: https://github.com/rust-lang/rust/pull/57167
119+
[57234]: https://github.com/rust-lang/rust/pull/57234
120+
[57234]: https://github.com/rust-lang/rust/pull/57234
121+
122+
Additionally, these APIs have become stable:
123+
124+
- [`unix::FileExt::read_exact_at`] and [`unix::FileExt::write_all_at`]
125+
- [`Option::transpose`] and [`Result::transpose`]
126+
- [`convert::identity`]
127+
- [`pin::Pin`] and [`marker::Unpin`] (mentioned above)
128+
- [`marker::PhantomPinned`]
129+
- [`Vec::resize_with`] and [`VecDeque::resize_with`]
130+
- [`Duration::as_millis`], [`Duration::as_micros`], and [`Duration::as_nanos`]
131+
132+
[`unix::FileExt::read_exact_at`]: https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#method.read_exact_at
133+
[`unix::FileExt::write_all_at`]: https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#method.write_all_at
134+
[`Option::transpose`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.transpose
135+
[`Result::transpose`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.transpose
136+
[`convert::identity`]: https://doc.rust-lang.org/std/convert/fn.identity.html
137+
[`pin::Pin`]: https://doc.rust-lang.org/std/pin/struct.Pin.html
138+
[`marker::Unpin`]: https://doc.rust-lang.org/stable/std/marker/trait.Unpin.html
139+
[`marker::PhantomPinned`]: https://doc.rust-lang.org/nightly/std/marker/struct.PhantomPinned.html
140+
[`Vec::resize_with`]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.resize_with
141+
[`VecDeque::resize_with`]: https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.resize_with
142+
[`Duration::as_millis`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_millis
143+
[`Duration::as_micros`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_micros
144+
[`Duration::as_nanos`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_nanos
145+
146+
See the [detailed release notes][notes] for more details.
147+
148+
### Cargo features
149+
150+
[Cargo should now rebuild a crate if a file was modified during the initial
151+
build.](https://github.com/rust-lang/cargo/pull/6484/)
152+
153+
See the [detailed release notes][notes] for more.
154+
155+
### Crates.io
156+
157+
[As previously announced][urlo-ann], coinciding with this release, crates.io
158+
will require that you have a verified email address to publish. Starting at
159+
2019-03-01 00:00 UTC, if you don't have a verified email address and run `cargo
160+
publish`, you'll get an error.
161+
162+
This ensures we can comply with DMCA procedures. If you haven't heeded the
163+
warnings cargo printed during the last release cycle, head on over to
164+
[crates.io/me][me] to set and verify your email address. This email address
165+
will never be displayed publicly and will only be used for crates.io operations.
166+
167+
[urlo-ann]: https://users.rust-lang.org/t/a-verified-email-address-will-be-required-to-publish-to-crates-io-starting-on-2019-02-28/22425
168+
[me]: https://crates.io/me
169+
170+
## Contributors to 1.33.0
171+
172+
Many people came together to create Rust 1.33.0. We couldn't have done it
173+
without all of you.

0 commit comments

Comments
 (0)
0