You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update mutable static items example for modern Rust.
This updates the mutable static item example to fix some issues with how
it works and how it is presented.
First, the unsafe operations are wrapped in an `unsafe` block so that it
doesn't trigger `unsafe_op_in_unsafe_fn`.
Second, it switches the mutation example to use addr_of_mut to avoid the
undefined behavior, and to compile correctly in 2024 edition.
Third, it rewrites the second example to be safe with a different
description. My understanding is that the original example was written
at a time when it was considered that any potential race condition was
considered unsafe. However, that is no longer a widely held view. The
example has been rewritten to illustrate the two different ways you can
wrap mutable static access.
0 commit comments