From 6cde9cea0e4aaa7a4e948e68cf4876983cec96d9 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 2 Feb 2022 12:39:23 +0100 Subject: [PATCH] Simplify spawn_unchecked lifetime transmute --- src/util.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/util.rs b/src/util.rs index 80810974..3d6ae5ae 100644 --- a/src/util.rs +++ b/src/util.rs @@ -50,12 +50,9 @@ impl ThreadSpawnUnchecked for std::thread::Builder { F: FnOnce() -> R + Send, R: 'static + Send, { - let f: Box R> = Box::new(f); - // ^ No need for `'_` inside function bodies - // v but this is more readable - let _: &Box R> = &f; - // Safety: same-layout since only a lifetime difference - let f: Box R> = std::mem::transmute(f); + let f: Box R + Send> = Box::new(f); + // SAFETY: same-layout since only a lifetime difference + let f: Box R + Send> = std::mem::transmute(f); self.spawn(f) } }