From b79b68763ae8adf797e8b38cddd5e3b5bb2252a0 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Mon, 4 Dec 2023 15:18:58 +1300 Subject: [PATCH] OnceLock: Add note about drop and statics --- library/std/src/sync/once_lock.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/std/src/sync/once_lock.rs b/library/std/src/sync/once_lock.rs index 52a4391324375..1e4eafe614b3d 100644 --- a/library/std/src/sync/once_lock.rs +++ b/library/std/src/sync/once_lock.rs @@ -14,7 +14,10 @@ use crate::sync::Once; /// # Examples /// /// Using `OnceCell` to store a function’s previously computed value (a.k.a. -/// ‘lazy static’ or ‘memoizing’): +/// ‘lazy static’ or ‘memoizing’). Since [`drop`] is not called for static +/// items at the end of the program (see [the +/// reference](https://doc.rust-lang.org/reference/destructors.html), objects +/// stored using this pattern will not have their destructors called. /// /// ``` /// use std::collections::HashMap;