diff --git a/src/appkit.rs b/src/appkit.rs index cc73eb8..89429d9 100644 --- a/src/appkit.rs +++ b/src/appkit.rs @@ -18,7 +18,7 @@ pub unsafe fn metal_layer_from_ns_view(view: NonNull) -> Layer { // SAFETY: Caller ensures that the view is valid. let obj = unsafe { view.cast::().as_ref() }; - // Check if the view is a CAMetalLayer + // Check if the view is a `CAMetalLayer`. if obj.is_kind_of::() { // SAFETY: Just checked that the view is a `CAMetalLayer`. let layer = unsafe { view.cast::().as_ref() }; @@ -27,10 +27,10 @@ pub unsafe fn metal_layer_from_ns_view(view: NonNull) -> Layer { pre_existing: true, }; } - // Otherwise assume the view is `NSView` + // Otherwise assume the view is `NSView`. let view = unsafe { view.cast::().as_ref() }; - // Check if the view contains a valid CAMetalLayer + // Check if the view contains a valid `CAMetalLayer`. let existing = unsafe { view.layer() }; if let Some(existing) = existing { if existing.is_kind_of::() { @@ -43,7 +43,7 @@ pub unsafe fn metal_layer_from_ns_view(view: NonNull) -> Layer { } } - // If the layer was not `CAMetalLayer`, allocate a new one for the view + // If the layer was not `CAMetalLayer`, allocate a new one for the view. let layer = unsafe { CAMetalLayer::new() }; unsafe { view.setLayer(Some(&layer)) }; view.setWantsLayer(true); diff --git a/src/uikit.rs b/src/uikit.rs index c1ccdf6..2bc4bf8 100644 --- a/src/uikit.rs +++ b/src/uikit.rs @@ -15,12 +15,12 @@ pub unsafe fn metal_layer_from_handle(handle: UiKitWindowHandle) -> Layer { /// pub unsafe fn metal_layer_from_ui_view(view: NonNull) -> Layer { - // SAFETY: Caller ensures that the view is a UIView + // SAFETY: Caller ensures that the view is a `UIView`. let view = unsafe { view.cast::().as_ref() }; let main_layer = view.layer(); - // Check if the view's layer is already a CAMetalLayer + // Check if the view's layer is already a `CAMetalLayer`. let render_layer = if main_layer.is_kind_of::() { // SAFETY: Just checked that the layer is a `CAMetalLayer`. let layer = unsafe { Retained::cast::(main_layer) }; @@ -29,11 +29,11 @@ pub unsafe fn metal_layer_from_ui_view(view: NonNull) -> Layer { pre_existing: true, } } else { - // If the main layer is not a CAMetalLayer, we create a CAMetalLayer - // sublayer and use it instead. + // If the main layer is not a `CAMetalLayer`, we create a + // `CAMetalLayer` sublayer and use it instead. // - // Unlike on macOS, we cannot replace the main view as UIView does not - // allow it (when NSView does). + // Unlike on macOS, we cannot replace the main view as `UIView` does + // not allow it (when `NSView` does). let layer = unsafe { CAMetalLayer::new() }; let bounds = main_layer.bounds();