Skip to content

Commit 8784679

Browse files
committed
Commit added.
1 parent c947eb7 commit 8784679

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

orion-interner/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@ pub fn to_static_str(s: &str) -> &'static str {
2828
let interner = GLOBAL_INTERNER.get_or_init(ThreadedRodeo::new);
2929
let key = interner.get_or_intern(s);
3030
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`.
3136
unsafe { std::mem::transmute::<&str, &'static str>(static_ref) }
3237
}

0 commit comments

Comments
 (0)