pub struct PhantomNotSend { /* private fields */ }Expand description
Types with PhantomNotSend won’t automatically implement Send
§Example
ⓘ
let not_send = not_send::PhantomNotSend;
std::thread::spawn(move || {
drop(not_send);
}).join().unwrap();ⓘ
error[E0277]: `*mut ()` cannot be sent between threads safely
--> src/lib.rs:13:20
|
6 | std::thread::spawn(move || {
| ------------------ ^------
| | |
| _|__________________within this `{closure@src/lib.rs:6:20: 6:27}`
| | |
| | required by a bound introduced by this call
7 | | drop(not_send);
8 | | }).join().unwrap();
| |_^ `*mut ()` cannot be sent between threads safely
|
= help: within `{closure@src/lib.rs:6:20: 6:27}`, the trait `Send` is not implemented for `*mut ()`, which is required by `{closure@src/lib.rs:6:20: 6:27}: Send`
note: required because it appears within the type `PhantomData<*mut ()>`
--> /Users/bajix/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/marker.rs:753:12
|
753 | pub struct PhantomData<T: ?Sized>;
| ^^^^^^^^^^^
note: required because it appears within the type `PhantomNotSend`
--> /Users/bajix/Projects/not-send/src/lib.rs:57:12
|
57 | pub struct PhantomNotSend {
| ^^^^^^^^^^^^^^
note: required because it's used within this closure
--> src/lib.rs:13:20
|
6 | std::thread::spawn(move || {
| ^^^^^^^
note: required by a bound in `spawn`
--> /Users/bajix/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/mod.rs:707:8
|
704 | pub fn spawn<F, T>(f: F) -> JoinHandle<T>
| ----- required by a bound in this function
...
707 | F: Send + 'static,
| ^^^^ required by this bound in `spawn`Trait Implementations§
Source§impl Clone for PhantomNotSend
impl Clone for PhantomNotSend
Source§fn clone(&self) -> PhantomNotSend
fn clone(&self) -> PhantomNotSend
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PhantomNotSend
impl Debug for PhantomNotSend
Source§impl Default for PhantomNotSend
impl Default for PhantomNotSend
Source§fn default() -> PhantomNotSend
fn default() -> PhantomNotSend
Returns the “default value” for a type. Read more
Source§impl Hash for PhantomNotSend
impl Hash for PhantomNotSend
Source§impl Ord for PhantomNotSend
impl Ord for PhantomNotSend
Source§fn cmp(&self, other: &PhantomNotSend) -> Ordering
fn cmp(&self, other: &PhantomNotSend) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PhantomNotSend
impl PartialEq for PhantomNotSend
Source§impl PartialOrd for PhantomNotSend
impl PartialOrd for PhantomNotSend
impl Eq for PhantomNotSend
impl StructuralPartialEq for PhantomNotSend
impl Sync for PhantomNotSend
Auto Trait Implementations§
impl Freeze for PhantomNotSend
impl RefUnwindSafe for PhantomNotSend
impl !Send for PhantomNotSend
impl Unpin for PhantomNotSend
impl UnwindSafe for PhantomNotSend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more