File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ impl TaskPool {
177
177
///
178
178
/// ```compile_fail
179
179
/// use bevy_tasks::TaskPool;
180
- /// fn compile_fail () {
180
+ /// fn scope_escapes_closure () {
181
181
/// let pool = TaskPool::new();
182
182
/// let foo = Box::new(42);
183
183
/// pool.scope(|scope| {
@@ -190,6 +190,20 @@ impl TaskPool {
190
190
/// });
191
191
/// }
192
192
/// ```
193
+ ///
194
+ /// ```compile_fail
195
+ /// use bevy_tasks::TaskPool;
196
+ /// fn cannot_borrow_from_closure() {
197
+ /// let pool = TaskPool::new();
198
+ /// pool.scope(|scope| {
199
+ /// let x = 1;
200
+ /// let y = &x;
201
+ /// scope.spawn(async move {
202
+ /// assert_eq!(*y, 1);
203
+ /// });
204
+ /// });
205
+ /// }
206
+ ///
193
207
pub fn scope < ' env , F , T > ( & self , f : F ) -> Vec < T >
194
208
where
195
209
F : for < ' scope > FnOnce ( & ' env Scope < ' scope , ' env , T > ) ,
You can’t perform that action at this time.
0 commit comments