Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

armanriazi•rust•static•vs•cons

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
}
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
2+7 =