Skip to content

Commit 10c7680

Browse files
committed
Add comment about the need for Cell
1 parent 8a80e3a commit 10c7680

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

crates/ark/src/plots/graphics_device.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ struct PlotContext {
104104
intrinsic_size: Option<IntrinsicSize>,
105105
}
106106

107+
/// Graphics device state: plot recording, rendering, and comm management.
108+
///
109+
/// Fields use `Cell`/`RefCell` for interior mutability because the R graphics
110+
/// device callbacks are C function pointers that receive `&DeviceContext` (via
111+
/// `Console::get().device_context()`). There is no way to thread `&mut` through
112+
/// R's callback registration layer. A future refactor could wrap the C-to-Rust
113+
/// bridge so that the Rust-facing hook methods receive `&mut self` explicitly,
114+
/// containing the `Console::get()` unsoundness in one place.
107115
pub(crate) struct DeviceContext {
108116
/// Channel for sending [IOPubMessage::DisplayData] and
109117
/// [IOPubMessage::UpdateDisplayData] to Jupyter frontends when plot events occur

0 commit comments

Comments
 (0)