safety comment formatting

This commit is contained in:
2025-09-25 00:35:20 -04:00
parent 055aaf757c
commit 6e5cce2617
2 changed files with 5 additions and 3 deletions

View File

@@ -41,6 +41,7 @@ pub struct WidgetId<W = AnyWidget> {
/// but they don't send drop messages to Ui.
/// Ideally I'd have an enum or something that lets you use either, but that doesn't seem worth it
/// right now; it's good enough and relatively cheap.
#[repr(C)]
pub struct StaticWidgetId<W = AnyWidget> {
pub(super) ty: TypeId,
pub(super) id: CopyId,
@@ -83,7 +84,7 @@ impl<W> WidgetId<W> {
}
pub fn as_any(&self) -> &WidgetId<AnyWidget> {
// safety: self is repr(C) and generic only used for phantom data
// SAFETY: self is repr(C) and generic only used for phantom data
unsafe { std::mem::transmute(self) }
}
@@ -92,7 +93,7 @@ impl<W> WidgetId<W> {
}
pub(super) fn cast_type<W2>(self) -> WidgetId<W2> {
// safety: self is repr(C) and generic only used for phantom data
// SAFETY: self is repr(C) and generic only used for phantom data
unsafe { std::mem::transmute(self) }
}
@@ -196,6 +197,7 @@ impl<W> StaticWidgetId<W> {
WidgetId::new(self.id.id(), self.ty, send.clone(), true)
}
pub fn any(self) -> StaticWidgetId<AnyWidget> {
// SAFETY: self is repr(C)
unsafe { std::mem::transmute(self) }
}
}