dear_implot3d/style/
tokens.rs1use crate::sys;
2use std::marker::PhantomData;
3use std::rc::Rc;
4
5#[must_use]
7pub struct StyleVarToken {
8 pub(super) was_popped: bool,
9 pub(super) _not_send_or_sync: PhantomData<Rc<()>>,
10}
11
12impl StyleVarToken {
13 pub fn pop(mut self) {
15 if self.was_popped {
16 panic!("Attempted to pop an ImPlot3D style var token twice.");
17 }
18 self.was_popped = true;
19 unsafe {
20 sys::ImPlot3D_PopStyleVar(1);
21 }
22 }
23}
24
25impl Drop for StyleVarToken {
26 fn drop(&mut self) {
27 if !self.was_popped {
28 unsafe {
29 sys::ImPlot3D_PopStyleVar(1);
30 }
31 }
32 }
33}
34
35#[must_use]
37pub struct StyleColorToken {
38 pub(super) was_popped: bool,
39 pub(super) _not_send_or_sync: PhantomData<Rc<()>>,
40}
41
42impl StyleColorToken {
43 pub fn pop(mut self) {
45 if self.was_popped {
46 panic!("Attempted to pop an ImPlot3D style color token twice.");
47 }
48 self.was_popped = true;
49 unsafe {
50 sys::ImPlot3D_PopStyleColor(1);
51 }
52 }
53}
54
55impl Drop for StyleColorToken {
56 fn drop(&mut self) {
57 if !self.was_popped {
58 unsafe {
59 sys::ImPlot3D_PopStyleColor(1);
60 }
61 }
62 }
63}
64
65#[must_use]
67pub struct ColormapToken {
68 pub(super) was_popped: bool,
69 pub(super) _not_send_or_sync: PhantomData<Rc<()>>,
70}
71
72impl ColormapToken {
73 pub fn pop(mut self) {
75 if self.was_popped {
76 panic!("Attempted to pop an ImPlot3D colormap token twice.");
77 }
78 self.was_popped = true;
79 unsafe {
80 sys::ImPlot3D_PopColormap(1);
81 }
82 }
83}
84
85impl Drop for ColormapToken {
86 fn drop(&mut self) {
87 if !self.was_popped {
88 unsafe {
89 sys::ImPlot3D_PopColormap(1);
90 }
91 }
92 }
93}