“ArmanRiaziruststatic” Código de respuesta

ArmanRiaziruststatic

All access to a static is safe, but there are a number of restrictions on statics:

The type must have the Sync trait bound to allow thread-safe access.
Constants cannot refer to statics.
ArmanRiazi

ArmanRiaziruststaticvScons

It can be confusing whether or not you should use a constant item or a static item. Constants should, in general, be preferred over statics unless one of the following are true:

Large amounts of data are being stored
The single-address property of statics is required.
Interior mutability is required.
{
Another difference between constants and static variables is that static variables can be mutable.
Accessing and modifying mutable static variables is unsafe
}
ArmanRiazi

Respuestas similares a “ArmanRiaziruststatic”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código