@@ -13,15 +13,10 @@ impl SpirvBuilder {
13
13
/// Watches the module for changes using [`notify`], rebuilding it upon changes.
14
14
///
15
15
/// 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
+ {
25
20
let path_to_crate = self
26
21
. path_to_crate
27
22
. as_ref ( )
@@ -79,15 +74,14 @@ impl SpirvBuilder {
79
74
}
80
75
}
81
76
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.
82
79
pub struct AcceptFirstCompile < ' a , T > ( & ' a mut Option < T > ) ;
83
80
84
81
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) ;
91
85
}
92
86
}
93
87
0 commit comments