(&self)
| 90 | return Ok(unsafe { Self::new_unchecked(existing) }); |
| 91 | } |
| 92 | let leaked: &'static str = Box::leak(path.to_owned().into_boxed_str()); |
| 93 | pool.insert(leaked); |
| 94 | // SAFETY: validate rejects paths outside ResPath grammar and leaked str is static. |
| 95 | Ok(unsafe { Self::new_unchecked(leaked) }) |
| 96 | } |
| 97 | |
| 98 | /// # Safety |
| 99 | /// |
| 100 | /// Caller must pass a valid resource path. |
| 101 | pub const unsafe fn new_unchecked(path: &'static str) -> &'static Self { |
| 102 | // SAFETY: ResPath is repr(transparent) over str; caller upholds path validity. |
| 103 | unsafe { &*(path as *const str as *const Self) } |
no outgoing calls
no test coverage detected