We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c947eb7 commit 8784679Copy full SHA for 8784679
orion-interner/src/lib.rs
@@ -28,5 +28,10 @@ pub fn to_static_str(s: &str) -> &'static str {
28
let interner = GLOBAL_INTERNER.get_or_init(ThreadedRodeo::new);
29
let key = interner.get_or_intern(s);
30
let static_ref = interner.resolve(&key);
31
+
32
+ // SAFETY: The `GLOBAL_INTERNER` is a `static` variable, meaning it has a `'static`
33
+ // lifetime and is never dropped. Therefore, the string slices stored within it
34
+ // are also valid for the `'static` lifetime. This transmute is safe because
35
+ // we are extending a lifetime that is already effectively `'static`.
36
unsafe { std::mem::transmute::<&str, &'static str>(static_ref) }
37
}
0 commit comments