Skip to main content

runmat_runtime/
plotting_hooks.rs

1//! Lightweight wrappers that expose plotting-specific helpers without requiring
2//! downstream crates to depend directly on the plotting feature flag.
3
4/// Reset the per-thread "figures touched" set. No-op when plotting is disabled.
5pub fn reset_recent_figures() {
6    #[cfg(feature = "plot-core")]
7    {
8        crate::builtins::plotting::reset_recent_figures();
9    }
10}
11
12/// Drain the per-thread "figures touched" set, returning the raw handles.
13pub fn take_recent_figures() -> Vec<u32> {
14    #[cfg(feature = "plot-core")]
15    {
16        crate::builtins::plotting::take_recent_figures()
17            .into_iter()
18            .map(|handle| handle.as_u32())
19            .collect()
20    }
21    #[cfg(not(feature = "plot-core"))]
22    {
23        Vec::new()
24    }
25}
26
27/// Record raw figure handles that were touched on another execution thread.
28pub fn record_recent_figures(handles: impl IntoIterator<Item = u32>) {
29    #[cfg(feature = "plot-core")]
30    {
31        for handle in handles {
32            crate::builtins::plotting::record_recent_figure(handle.into());
33        }
34    }
35    #[cfg(not(feature = "plot-core"))]
36    {
37        let _ = handles;
38    }
39}