Stricter Memory Safety Rules: Introducing Child Groups
This article introduces a stricter memory safety rule by introducing the concept of "child groups." The old rule was too lenient; the new rule more precisely defines which references need to be invalidated when an object is mutated. Using the `Entity` struct as an example, the article explains how to distinguish between the object itself and its "child groups" (e.g., elements in a list, objects pointed to by pointers). The new rule states that when an object might be modified, references to the object itself remain valid, but references to child groups become invalid. Through code examples, the article clearly demonstrates how the new rule enhances memory safety and avoids dangling pointers.
Read more