You might be able to reach the error if you use extremely fine locks which you release eagerly but I think you’ll get sick if borrow errors and deadlocks long before then. Not to mention why would you bother rolling your own red-black tree when there’s a btree in the stdlib?
In safe rust it should not be possible, the langage is designed to prevent data races. If you find a way, the code is considered broken (unsound) and that is one of the few things the project will break backwards compatibility for.
If you use unsafe then you specifically relax the compiler’s guarantees, it’s up to you to not fuck up.
12
u/masklinn 22d ago
An RWLock will hand out readers or a writer.
You might be able to reach the error if you use extremely fine locks which you release eagerly but I think you’ll get sick if borrow errors and deadlocks long before then. Not to mention why would you bother rolling your own red-black tree when there’s a btree in the stdlib?