tamanegi_error/
location.rs1use core::ops::Deref;
2use snafu::GenerateImplicitData;
3
4pub struct StaticLocationRef(&'static core::panic::Location<'static>);
5
6impl Deref for StaticLocationRef {
7 type Target = core::panic::Location<'static>;
8 fn deref(&self) -> &core::panic::Location<'static> {
9 self.0
10 }
11}
12
13impl core::fmt::Debug for StaticLocationRef {
14 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
15 core::write!(f, "{}:{}:{}", self.file(), self.line(), self.column())
16 }
17}
18
19impl GenerateImplicitData for StaticLocationRef {
20 #[track_caller]
21 fn generate() -> Self {
22 Self(core::panic::Location::caller())
23 }
24}