Return the currently-active [`ResolvedClassCache`], if any. Returns `None` when no [`with_active_resolved_class_cache`] guard is alive on this thread. # Safety The returned reference borrows the cache through a raw pointer set by [`with_active_resolved_class_cache`]. This is safe because the pointer is only non-null while the [`ResolvedCacheGuard`] (which holds a borrow of the original `&Resol
()
| 153 | /// pointer is only non-null while the [`ResolvedCacheGuard`] (which |
| 154 | /// holds a borrow of the original `&ResolvedClassCache`) is alive. |
| 155 | pub fn active_resolved_class_cache() -> Option<&'static ResolvedClassCache> { |
| 156 | let ptr = ACTIVE_RESOLVED_CACHE.with(|c| c.get()); |
| 157 | if ptr.is_null() { |
| 158 | None |
| 159 | } else { |
| 160 | // SAFETY: ptr was set from a valid &ResolvedClassCache reference |
| 161 | // and the ResolvedCacheGuard that owns the borrow is still alive |
| 162 | // (it clears the pointer on drop). |
| 163 | Some(unsafe { &*ptr }) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | /// Evict all cache entries whose FQN matches the given name, then |
| 168 | /// transitively evict any cached class that depends on the evicted |
no test coverage detected