Static mut variables in Rust2024

⚓ rust    📅 2025-05-24    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 35 days ago. The information described in this article may have changed.

A few books have still examples for static mut variables. So I added one myself, telling that one should avoid them. But I think in last year the example was compiling, but now with Rust 2024 it fails in the playground, and I am unsure how I should modify the example and the text. The easiest way would be to just say that use of static mut is not longer permitted. Is that good enough? I discovered that a #![allow(static_mut_refs)] makes it compile in the playground. I will try to give a link to the playground example code, it is from section Variables and mutability - Rust for C-Programmers of the book.

5 posts - 2 participants

Read full topic

🏷️ rust_feed