Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [4:50 PM]Protty: how does one send a *const T to another thread? I tried wrapping it in a custom type and doing unsafe impl Send on it but rust ignores that for some reason
- [4:50 PM]Inferno, Clever-ISA Shill: :thonk:
- [4:50 PM]Inferno, Clever-ISA Shill: That should work
- [4:51 PM]LegionMammal978: Did you move the entire wrapper? In the 2021 edition, if you only use wrapper.0 in the closure, it will try to capture the *const T directly
- [4:52 PM]Protty: I tried let w = Wrapper(x); spawn(move || { let Wrapper(x) = w }) with no luck
- [4:52 PM]Protty: nightly btw
- [4:53 PM]Protty: Heres the code. Ignoring that error, its a scoped thread impl that should be more efficient than crossbeams & probably stdlib: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=9564abdf35fb173f108ea748ee7ad312
- [4:54 PM]LegionMammal978: Yep, you need a let w = w; before that
- [4:54 PM]Protty: cringe
- [4:54 PM]LegionMammal978: Alternatively, impl<T: ?Sized> Deref for Wrapper<T> { ... }, and let x = *w;
- [4:54 PM]Inferno, Clever-ISA Shill: Welcome to rust 2021
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement