Rust 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 beoogt moderne computersystemen efficiënter te benutten. Het wordt ingezet door onder andere Cloudflare, OVH, Mozilla, Deliveroo, Coursera, AppSignal en Threema. Versie 1.80 is uitgebracht en de releasenotes voor die uitgave kunnen hieronder worden gevonden.
LazyCell
andLazyLock
These "lazy" types delay the initialization of their data until first access. They are similar to the
OnceCell
andOnceLock
types stabilized in 1.70, but with the initialization function included in the cell. This completes the stabilization of functionality adopted into the standard library from the popularlazy_static
andonce_cell
crates.
LazyLock
is the thread-safe option, making it suitable for places likestatic
values. For example, both thespawn
thread and the mainscope
will see the exact same duration below, sinceLAZY_TIME
will be initialized once, by whichever ends up accessing the static first. Neither use has to know how to initialize it, unlike they would withOnceLock::get_or_init()
.Checked
LazyCell
does the same thing without thread synchronization, so it doesn't implementSync
, which is needed forstatic
, but it can still be used inthread_local!
statics (with distinct initialization per thread). Either type can also be used in other data structures as well, depending on thread-safety needs, so lazy initialization is available everywhere!cfg
names and valuesIn 1.79,
rustc
stabilized a--check-cfg
flag, and now Cargo 1.80 is enabling those checks for allcfg
names and values that it knows (in addition to the well known names and values fromrustc
). This includes feature names fromCargo.toml
as well as newcargo::rustc-check-cfg
output from build scripts.Unexpected cfgs are reported by the warn-by-default
unexpected_cfgs
lint, which is meant to catch typos or other misconfiguration. For example, in a project with an optionalrayon
dependency, this code is configured for the wrongfeature
value. The same warning is reported regardless of whether the actualrayon
feature is enabled or not.The
[lints]
table in theCargo.toml
manifest can also be used to extend the list of known names and values for customcfg
.rustc
automatically provides the syntax to use in the warning.[lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] }
You can read more about this feature in a previous blog post announcing the availability of the feature on nightly.
Exclusive ranges in patternsRust ranged patterns can now use exclusive endpoints, written
a..b
or..b
similar to theRange
andRangeTo
expression types. For example, the following patterns can now use the same constants for the end of one pattern and the start of the next:Previously, only inclusive (
a..=b
or..=b
) or open (a..
) ranges were allowed in patterns, so code like this would require separate constants for inclusive endpoints likeK - 1
.Exclusive ranges have been implemented as an unstable feature for a long time, but the blocking concern was that they might add confusion and increase the chance of off-by-one errors in patterns. To that end, exhaustiveness checking has been enhanced to better detect gaps in pattern matching, and new lints
Stabilized APIsnon_contiguous_range_endpoints
andoverlapping_range_endpoints
will help detect cases where you might want to switch exclusive patterns to inclusive, or vice versa.
impl Default for Rc<CStr>
impl Default for Rc<str>
impl Default for Rc<[T]>
impl Default for Arc<str>
impl Default for Arc<CStr>
impl Default for Arc<[T]>
impl IntoIterator for Box<[T]>
impl FromIterator<String> for Box<str>
impl FromIterator<char> for Box<str>
LazyCell
LazyLock
Duration::div_duration_f32
Duration::div_duration_f64
Option::take_if
Seek::seek_relative
BinaryHeap::as_slice
NonNull::offset
NonNull::byte_offset
NonNull::add
NonNull::byte_add
NonNull::sub
NonNull::byte_sub
NonNull::offset_from
NonNull::byte_offset_from
NonNull::read
NonNull::read_volatile
NonNull::read_unaligned
NonNull::write
NonNull::write_volatile
NonNull::write_unaligned
NonNull::write_bytes
NonNull::copy_to
NonNull::copy_to_nonoverlapping
NonNull::copy_from
NonNull::copy_from_nonoverlapping
NonNull::replace
NonNull::swap
NonNull::drop_in_place
NonNull::align_offset
<[T]>::split_at_checked
<[T]>::split_at_mut_checked
str::split_at_checked
str::split_at_mut_checked
str::trim_ascii
str::trim_ascii_start
str::trim_ascii_end
<[u8]>::trim_ascii
<[u8]>::trim_ascii_start
<[u8]>::trim_ascii_end
Ipv4Addr::BITS
Ipv4Addr::to_bits
Ipv4Addr::from_bits
Ipv6Addr::BITS
Ipv6Addr::to_bits
Ipv6Addr::from_bits
Vec::<[T; N]>::into_flattened
<[[T; N]]>::as_flattened
<[[T; N]]>::as_flattened_mut
These APIs are now stable in const contexts:
Other changesCheck out everything that changed in Rust, Cargo, and Clippy.