safety comment formatting
This commit is contained in:
@@ -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) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ impl Widgets {
|
||||
/// get_dyn but dynamic borrow checking of widgets
|
||||
/// lets you do recursive (tree) operations, like the painter does
|
||||
pub fn get_dyn_dynamic(&self, id: &Id) -> WidgetWrapper<'_> {
|
||||
// must guarantee no other mutable references to this widget exist
|
||||
// SAFETY: must guarantee no other mutable references to this widget exist
|
||||
// done through the borrow variable
|
||||
let data: &mut WidgetData = unsafe { std::mem::transmute(self.map.get(id)) };
|
||||
if data.borrowed {
|
||||
|
||||
Reference in New Issue
Block a user