Skip to content

Commit

Permalink
Document RustcEncodable/RustcDecodable
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Apr 16, 2024
1 parent 7ffa639 commit e70a1d2
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/rust-2024/prelude.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ More information may be found in the tracking issue at <https://github.com/rust-

- The [`Future`] and [`IntoFuture`] traits are now part of the prelude.
- This might make calls to trait methods ambiguous which could make some code fail to compile.
- `RustcEncodable` and `RustcDecodable` have been removed from the prelude.

[`Future`]: ../../std/future/trait.Future.html
[`IntoFuture`]: ../../std/future/trait.IntoFuture.html
Expand All @@ -26,10 +27,24 @@ However, adding a _trait_ to the prelude can break existing code in a subtle way
For example, a call to `x.poll()` which comes from a `MyPoller` trait might fail to compile if `std`'s `Future` is also imported, because the call to `poll` is now ambiguous and could come from either trait.

As a solution, Rust 2024 will use a new prelude.
It's identical to the current one, except for two new additions:
It's identical to the current one, except for the following changes:

- [`std::future::Future`][`Future`]
- [`std::future::IntoFuture`][`IntoFuture`]
- Added:
- [`std::future::Future`][`Future`]
- [`std::future::IntoFuture`][`IntoFuture`]
- Removed:
- `RustcEncodable`
- `RustcDecodable`

### `RustcEncodable` and `RustcDecodable` removal

`RustcEncodable` and `RustcDecodable` are two undocumented derive macros that have been removed from the prelude.
These were deprecated before Rust 1.0, but remained within the standard library prelude.
The 2024 Edition has removed these from the prelude since they are not expected to be used.

If in the unlikely case there is a project still using these, it is recommended to switch to a serialization library, such as those found on [crates.io].

[crates.io]: https://crates.io/categories/encoding

## Migration

Expand Down Expand Up @@ -67,3 +82,12 @@ fn main() {
<_ as MyPoller>::poll(&core::pin::pin!(async {}));
}
```

#### `RustcEncodable` and `RustcDecodable`

It is strongly recommended that you migrate to a different serialization library if you are still using these.
However, these derive macros are still available in the standard library, they are just required to be imported from the older prelude now:

```rust,edition2021
use core::prelude::v1::{RustcDecodable, RustcEncodable};
```

0 comments on commit e70a1d2

Please sign in to comment.