Skip to content

Comment on Too dangerous for C++parent

Comments

Because Rust has a safety culture, and provides threading, it is crucial that that the compiler will reject types you cannot safely send to another thread. So it does.

So the "diagnostic against misuse" you're concerned about is a necessary part of the compiler anyway.

Indeed, although Rc has this line:

  impl<T: ?Sized, A: Allocator> !Send for Rc<T, A> {}
(which means roughly "You can't send this type to another thread")

It also has these lines:

  // Note that this negative impl isn't strictly necessary for correctness,
  // as `Rc` transitively contains a `Cell`, which is itself `!Sync`.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.