Skip to content

Commit 3150cbc

Browse files
committed
feat(blog): New article about anticipated features in Rust
1 parent 1050215 commit 3150cbc

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: Features I'm looking forward to in Rust
3+
tagline: "Something about waiting for godot, look I don't know man
4+
tags: ["rust", "programming"]
5+
date: 2025-09-23
6+
---
7+
8+
BigRustFan23 here: I genuinely enjoy my time programming in Rust. For every reason that has already been said: Incredibly empowering, great docs, great tooling etc.
9+
10+
But, as my projects and ambitions grow bigger, I keep hitting a few unstable / currently not implemented features. In this article, I'll list which ones and why I'd like to see them.
11+
12+
> Latest release was 1.89.0 when this was written.
13+
14+
## In Rust itself
15+
16+
### Permit Impl Trait in type aliases
17+
18+
Tracking issue: https://github.com/rust-lang/rust/issues/63063
19+
20+
You currently can't do something like this:
21+
22+
```rust
23+
type PageResult = impl Into<RenderResult>
24+
```
25+
26+
which would be useful to provide more concise signatures in traits especially, where users have to retype the signature from your trait. In a similar vein, [trait aliases](https://github.com/rust-lang/rust/issues/41517) would also help with similar goals in certain contexts.
27+
28+
### Bounds on generic parameters in type aliases are not enforced
29+
30+
Tracking issue: https://github.com/rust-lang/rust/issues/112792
31+
32+
The following example compiles and runs just fine, even though &str does not implement `Into<i32>` (or `i32` does not implement `From<&str>`)
33+
34+
```rust
35+
type PositiveNumber<T: Into<i32>> = T;
36+
37+
fn main() {
38+
let something: PositiveNumber<&str> = "Hello";
39+
}
40+
```
41+
42+
In general this ends up not being a big problem because the expected bound will end up getting enforced elsewhere and there are plenty of workarounds (such as using a newtype instead of just a type alias), but would still be neat.
43+
44+
### Associated type defaults
45+
46+
Tracking issue: https://github.com/rust-lang/rust/issues/29661
47+
48+
[Associated types](https://doc.rust-lang.org/rust-by-example/generics/assoc_items/types.html) cannot be provided defaults, as such adding them to a trait currently requires users to always specify them, even if they wanted some sort of default value.
49+
50+
For example, in the following trait:
51+
52+
```rust
53+
trait Greeter {
54+
type Message: Into<String>;
55+
56+
fn greet(&self) -> Self::Message;
57+
}
58+
```
59+
60+
Users always needs to specify the type of `Message` when implementing the trait:
61+
62+
```rust
63+
struct Hello;
64+
65+
impl Greeter for Hello {
66+
type Message = &'static str;
67+
68+
fn greet(&self) -> Self::Message {
69+
"Hello, world!"
70+
}
71+
}
72+
```
73+
74+
But, realistically, a fair percent of the users of the trait will probably want the same thing and so having to specify the type every time is cumbersome and verbose, especially if there are multiple types or generics are involved and stuff.
75+
76+
### Entry APIs for HashSet
77+
78+
Tracking issue: https://github.com/rust-lang/rust/issues/60896
79+
80+
The Entry API on HashMap allows for quite ergonomic handling of already existing values, in addition to avoiding sometimes needing double or triple lookups to return stuff.
81+
82+
Perhaps I'm architecting my code wrong, but I feel like notably `get_or_insert` for HashSet would make a huge difference on my code.
83+
84+
## In rustfmt
85+
86+
### Format Rust code inside Markdown
87+
88+
Tracking issue: https://github.com/rust-lang/rustfmt/issues/2036
89+
90+
Would be very useful to ensure Rust code blocks (such as the one in this article) are properly formatted.
91+
92+
## In rust-analyzer
93+
94+
### Organize Imports
95+
96+
Tracking issue: https://github.com/rust-lang/rust-analyzer/issues/5131
97+
98+
While [rustfmt does have the ability to reorder imports](https://rust-lang.github.io/rustfmt/?version=v1.8.0&search=#reorder_imports), rust-analyzer, typically extremely useful and surprisingly complete and meticulous at times lacks support for the [organizeImports code action](https://code.visualstudio.com/docs/typescript/typescript-refactoring#_organize-imports).
99+
100+
With this, triggering the action through the command palette (or on save if configured to do so), rust-analyzer would automatically remove unused imports. I'll note that it is somewhat possible to do this already, by selecting all the imports, pressing `CTRL+.` and manually clicking a "Remove all unused imports" option, but it's a bit cumbersome.
101+
102+
dinkus
103+
104+
Rust is often criticised for its complex syntax, and asking for more features might make it seems like it'd make things even worse. However, I actually believe that giving library authors the features that allow them to create APIs with less boilerplate would help a lot with this perception.
105+
106+
Until then, I'm using nightly (I'm not)

0 commit comments

Comments
 (0)