Software-update: Rust 1.88.0

Rust logoRust is een programmeertaal bedacht door Graydon Hoare en oorspronkelijk ontwikkeld door Mozilla. Het is deels geïnspireerd op de programmeertaal C, maar kent syntactische en semantische verschillen. Het focust op veiligheid en moet moderne computersystemen efficiënter benutten. Het wordt ingezet door onder andere Cloudflare, OVH, Mozilla, Deliveroo, Coursera, AppSignal en Threema. Versie 1.88 is uitgebracht en de releasenotes voor die uitgave kunnen hieronder worden gevonden.

Let chains

This feature allows &&-chaining let statements inside if and while conditions, even intermingling with boolean expressions, so there is less distinction between if/if let and while/while let. The patterns inside the let sub-expressions can be irrefutable or refutable, and bindings are usable in later parts of the chain as well as the body.

For example, this snippet combines multiple conditions which would have required nesting if let and if blocks before:

if let Channel::Stable(v) = release_info()
    && let Semver { major, minor, .. } = v
    && major == 1
    && minor == 88
{
    println!("`let_chains` was stabilized in this version");
}

Let chains are only available in the Rust 2024 edition, as this feature depends on the if let temporary scope change for more consistent drop order.

Earlier efforts tried to work with all editions, but some difficult edge cases threatened the integrity of the implementation. 2024 made it feasible, so please upgrade your crate's edition if you'd like to use this feature!

Naked functions

Rust now supports writing naked functions with no compiler-generated epilogue and prologue, allowing full control over the generated assembly for a particular function. This is a more ergonomic alternative to defining functions in a global_asm! block. A naked function is marked with the #[unsafe(naked)] attribute, and its body consists of a single naked_asm! call. For example:

#[unsafe(naked)]
pub unsafe extern "sysv64" fn wrapping_add(a: u64, b: u64) -> u64 {
    // Equivalent to `a.wrapping_add(b)`.
    core::arch::naked_asm!(
        "lea rax, [rdi + rsi]",
        "ret"
    );
}

The handwritten assembly block defines the entire function body: unlike non-naked functions, the compiler does not add any special handling for arguments or return values. Naked functions are used in low-level settings like Rust's compiler-builtins, operating systems, and embedded applications. Look for a more detailed post on this soon!

Boolean configuration

The cfg predicate language now supports boolean literals, true and false, acting as a configuration that is always enabled or disabled, respectively. This works in Rust conditional compilation with cfg and cfg_attr attributes and the built-in cfg! macro, and also in Cargo [target] tables in both configuration and manifests.

Previously, empty predicate lists could be used for unconditional configuration, like cfg(all()) for enabled and cfg(any()) for disabled, but this meaning is rather implicit and easy to get backwards. cfg(true) and cfg(false) offer a more direct way to say what you mean. See RFC 3695 for more background!

Cargo automatic cache cleaning

Starting in 1.88.0, Cargo will automatically run garbage collection on the cache in its home directory!

When building, Cargo downloads and caches crates needed as dependencies. Historically, these downloaded files would never be cleaned up, leading to an unbounded amount of disk usage in Cargo's home directory. In this version, Cargo introduces a garbage collection mechanism to automatically clean up old files (e.g. .crate files). Cargo will remove files downloaded from the network if not accessed in 3 months, and files obtained from the local system if not accessed in 1 month. Note that this automatic garbage collection will not take place if running offline (using --offline or --frozen).

Cargo 1.78 and newer track the access information needed for this garbage collection. This was introduced well before the actual cleanup that's starting now, in order to reduce cache churn for those that still use prior versions. If you regularly use versions of Cargo even older than 1.78, in addition to running current versions of Cargo, and you expect to have some crates accessed exclusively by the older versions of Cargo and don't want to re-download those crates every ~3 months, you may wish to set cache.auto-clean-frequency = "never" in the Cargo configuration, as described in the docs.

For more information, see the original unstable announcement of this feature. Some parts of that design remain unstable, like the gc subcommand tracked in cargo#13060, so there's still more to look forward to!

Stabilized APIs These previously stable APIs are now stable in const contexts: Other changes

The i686-pc-windows-gnu target has been demoted to Tier 2, as mentioned in an earlier post. This won't have any immediate effect for users, since both the compiler and standard library tools will still be distributed by rustup for this target. However, with less testing than it had at Tier 1, it has more chance of accumulating bugs in the future.

Check out everything that changed in Rust, Cargo, and Clippy.

Rust

Versienummer 1.88.0
Releasestatus Final
Website The Rust Programming Language Blog
Download https://www.rust-lang.org/install.html
Licentietype Voorwaarden (GNU/BSD/etc.)

Door Bart van Klaveren

Downloads en Best Buy Guide

27-06-2025 • 10:30

8

Submitter: danmark_ori

Bron: The Rust Programming Language Blog

Update-historie

27-06 Rust 1.88.0 8
16-05 Rust 1.87.0 1
04-04 Rust 1.86.0 0
21-02 Rust 1.85.0 0
31-01 Rust 1.84.1 0
10-01 Rust 1.84.0 0
29-11 Rust 1.83.0 5
09-'24 Rust 1.81.0 1
07-'24 Rust 1.80.0 8
04-'24 Rust 1.77.2 7
Meer historie

Reacties (8)

8
8
3
0
0
4
Wijzig sortering
De nieuwe teksteditor "Edit" van Microsoft is ook volledig in Rust geschreven: https://github.com/microsoft/edit
Microsoft zou dus nog een mooie toevoeging zijn aan het lijstje "Het wordt ingezet door onder andere ..."
Microsoft gebruikte Rust al in de Windows kernel. Ik weet niet in elke mate maar het toont wel aan dat Microsoft heel serieus met Rust bezig is.

https://www.techtarget.com/searchenterprisedesktop/answer/Does-Windows-kernel-use-Rust-and-what-does-it-mean-for-IT
Dit artikel moet je wel niet al te letterlijk nemen. De zin “is the kernel implemented in Rust, yes” is wel een beetje misleidend vind ik. Ze hebben inderdaad een aantal drivers geschreven in Rust en ik meen ook aangegeven nieuwe development in Rust te doen. Maar het zeer grote deel, misschien zelfs 95%+ is nog steeds c++, C en assembly.

Microsoft is er wel inderdaad mee bezig, maar naar mijn mening mag de adaption rate bij alle bedrijven nog wel wat hoger.


Zit zelf ook nog steeds in dubio. Soms verbaast Rust me wat soms erg eenvoudig en duidelijk is. Soms is het echt een cryptische bedoeling omdat de syntax zo vreemd is vind ik, tegenover een C based taal.

[Reactie gewijzigd door Powerblast op 27 juni 2025 13:43]

Oh, maar het wordt ook op heel veel plekken al gebruikt. Alleen is dat vaak niet zo goed te zien.

Microsoft heeft bijvoorbeeld ook deze github organization: https://github.com/OpenDevicePartnership
Hier schrijven ze embedded Rust om dat in (windows) laptops en tablets te stoppen. Ik heb het geluk vanuit mijn werk hieraan mee te mogen werken :)

Ik heb ook al eens een soort interview gedaan met iemand van Volvo over hoe ze (embedded) Rust gebruiken: https://tweedegolf.nl/en/blog/137/rust-is-rolling-off-the-volvo-assembly-line

Ik heb zelfs al eens over bedrijven in bepaalde sectoren gehoord dat ze op hun vacatures heel bewust geen Rust zetten en alleen C++ terwijl ze voornamelijk in Rust schrijven. Op die manier zouden ze de concurrentie niet wijzer maken dan nodig. Het gebruik van Rust zou dan ook een competitive advantage zijn. Maar goed, ik zit niet in die sector. De man die me dit vertelde kon ook uit zijn nek kletsen...
Dit artikel moet je wel niet al te letterlijk nemen. De zin “is the kernel implemented in Rust, yes” is wel een beetje misleidend vind ik.
Niet voor niets schreef ik (heel bewust) "ik weet niet in welke mate" omdat ik ook wel snap dat Microsoft niet even een kernel, die 35 jaar ontwikkeling achter zich heeft, volledig omzet naar Rust.

Ik ben zelf ook beetje kritisch op de Rust-hype. Mooie taal voor nieuwe projecten en nieuwe functionaliteit, daar twijfel ik niet aan, maar ik vraag me af of het loont om bestaande software opnieuw te implementeren alleen maar omdat er nu een betere taal is. Rewrites zijn nu eenmaal niet altijd beter dan (verder) perfectioneren wat je al hebt.
Drukte voor de grap eens de Clippy documentatie aan, maar best interessant om te lezen! Hele hoop anti-patterns waar ik eigenlijk nog nooit aan gedacht had
Eerlijk ik gebruik Clippy vaak om te leren, het is heel handig omdat hoewel de code misschien werkt het veel suggesties geeft over manieren die efficienter zijn. Dus zeker wanneer je begint is het well handig want je ontdekt vaak ook nieuwe dingen die de taal zelf kan

[Reactie gewijzigd door Stetsed op 27 juni 2025 11:52]

Hoe komen jullie erbij dat Rust geïnspireerd is op C? Als er zaken als inspiratie uit C gehaald zijn, is het hoe zaken NIET te doen.

Rust heeft inspiratie gehaald uit OCaml.

Op dit item kan niet meer gereageerd worden.