作用域规则

作用域在所有权(ownership)、借用(borrowing)和生命周期(lifetime)中起着重要作用。也就是说,当借用有效,当资源可以释放,还有当变量被创建或销毁时,作用域都在指导编译器(原文:That is, they indicate to the compiler when borrows are valid, when resources can be freed, and when variables are created or destroyed.)。