Skip to content

Commit c5fbc8b

Browse files
committed
Make AcceptFirstCompile public
1 parent ad2a34a commit c5fbc8b

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

crates/spirv-builder/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub use rustc_codegen_spirv_types::Capability;
9292
pub use rustc_codegen_spirv_types::{CompileResult, ModuleResult};
9393

9494
#[cfg(feature = "watch")]
95-
pub use self::watch::Watch;
95+
pub use self::watch::{AcceptFirstCompile, Watch};
9696

9797
#[cfg(feature = "include-target-specs")]
9898
pub use rustc_codegen_spirv_target_specs::TARGET_SPEC_DIR_PATH;

crates/spirv-builder/src/watch.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@ impl SpirvBuilder {
1313
/// Watches the module for changes using [`notify`], rebuilding it upon changes.
1414
///
1515
/// Calls `on_compilation_finishes` after each successful compilation.
16-
/// The second `Option<AcceptFirstCompile<T>>` param allows you to return some `T`
17-
/// on the first compile, which is then returned by this function
18-
/// in pair with [`JoinHandle`] to the watching thread.
19-
pub fn watch<T>(
20-
&self,
21-
mut on_compilation_finishes: impl FnMut(CompileResult, Option<AcceptFirstCompile<'_, T>>)
22-
+ Send
23-
+ 'static,
24-
) -> Result<Watch<T>, SpirvBuilderError> {
16+
pub fn watch<T, F>(&self, mut on_compilation_finishes: F) -> Result<Watch<T>, SpirvBuilderError>
17+
where
18+
F: FnMut(CompileResult, Option<AcceptFirstCompile<'_, T>>) + Send + 'static,
19+
{
2520
let path_to_crate = self
2621
.path_to_crate
2722
.as_ref()
@@ -79,15 +74,14 @@ impl SpirvBuilder {
7974
}
8075
}
8176

77+
/// The second parameter of the callback passed to [`SpirvBuilder::watch()`]
78+
/// which allows it to return some value of `T` on the first compile.
8279
pub struct AcceptFirstCompile<'a, T>(&'a mut Option<T>);
8380

8481
impl<'a, T> AcceptFirstCompile<'a, T> {
85-
pub fn new(write: &'a mut Option<T>) -> Self {
86-
Self(write)
87-
}
88-
89-
pub fn submit(self, t: T) {
90-
*self.0 = Some(t);
82+
/// Accepts some value of `T` to be later returned by [`SpirvBuilder::watch()`].
83+
pub fn submit(self, value: T) {
84+
*self.0 = Some(value);
9185
}
9286
}
9387

tests/difftests/lib/src/scaffold/compute/wgpu.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ where
6464
#[cfg(target_os = "windows")]
6565
dx12: wgpu::Dx12BackendOptions {
6666
shader_compiler: wgpu::Dx12Compiler::StaticDxc,
67-
..Default::default()
6867
},
6968
..Default::default()
7069
},

0 commit comments

Comments
 (0)