From 0cc8393b2c5cc58e6a80a0415ee0bede4650fb6a Mon Sep 17 00:00:00 2001 From: Taylor Holliday Date: Sun, 20 Aug 2023 16:47:48 -0700 Subject: [PATCH] add ContextId --- src/context.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/context.rs b/src/context.rs index f8475b2..786ad7c 100644 --- a/src/context.rs +++ b/src/context.rs @@ -48,6 +48,11 @@ pub struct RenderInfo<'a> { pub queue: &'a wgpu::Queue, } +#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] +pub(crate) struct ContextId { + pub id: u64 +} + /// The Context stores all UI state. A user of the library /// shouldn't have to interact with it directly. pub struct Context { @@ -127,7 +132,7 @@ thread_local! { pub(crate) static CONTEXT: RefCell = RefCell::new(Context::new()); } -pub(crate) fn with_context(f: impl FnOnce(&mut Context) -> T) -> T { +pub(crate) fn with_context(id: ContextId, f: impl FnOnce(&mut Context) -> T) -> T { CONTEXT.with(|cx| f(&mut cx.borrow_mut())) }