We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
thread_local
local_key_cell_methods
1 parent f6bd083 commit 6bc2415Copy full SHA for 6bc2415
src/subtyping.md
@@ -310,9 +310,7 @@ thread_local! {
310
311
/// saves the input given into a thread local `Vec<&'static str>`
312
fn store(input: &'static str) {
313
- StaticVecs.with(|v| {
314
- v.borrow_mut().push(input);
315
- })
+ StaticVecs.with_borrow_mut(|v| v.push(input));
316
}
317
318
/// Calls the function with it's input (must have the same lifetime!)
@@ -332,9 +330,8 @@ fn main() {
332
330
demo(&smuggle, store);
333
331
334
335
336
- println!("{:?}", v.borrow()); // use after free 😿
337
- });
+ // use after free 😿
+ StaticVecs.with_borrow(|v| println!("{v:?}"));
338
339
```
340
0 commit comments