mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-26 05:44:26 +00:00
document undefined collection behavior with interior mutability
closes #23327
This commit is contained in:
parent
ee7696383f
commit
90f06ae33f
@ -163,6 +163,11 @@ use vec::{self, Vec};
|
|||||||
/// A priority queue implemented with a binary heap.
|
/// A priority queue implemented with a binary heap.
|
||||||
///
|
///
|
||||||
/// This will be a max-heap.
|
/// This will be a max-heap.
|
||||||
|
///
|
||||||
|
/// It is a logic error for an item to be modified in such a way that the
|
||||||
|
/// item's ordering relative to any other item, as determined by the `Ord`
|
||||||
|
/// trait, changes while it is in the heap. This is normally only possible
|
||||||
|
/// through `Cell`, `RefCell`, global state, I/O, or unsafe code.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct BinaryHeap<T> {
|
pub struct BinaryHeap<T> {
|
||||||
|
@ -64,6 +64,10 @@ use super::node::{self, Node, Found, GoDown};
|
|||||||
/// and possibly other factors. Using linear search, searching for a random element is expected
|
/// and possibly other factors. Using linear search, searching for a random element is expected
|
||||||
/// to take O(B log<sub>B</sub>n) comparisons, which is generally worse than a BST. In practice,
|
/// to take O(B log<sub>B</sub>n) comparisons, which is generally worse than a BST. In practice,
|
||||||
/// however, performance is excellent.
|
/// however, performance is excellent.
|
||||||
|
///
|
||||||
|
/// It is a logic error for a key to be modified in such a way that the key's ordering relative to
|
||||||
|
/// any other key, as determined by the `Ord` trait, changes while it is in the map. This is
|
||||||
|
/// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct BTreeMap<K, V> {
|
pub struct BTreeMap<K, V> {
|
||||||
|
@ -30,6 +30,10 @@ use Bound;
|
|||||||
///
|
///
|
||||||
/// See BTreeMap's documentation for a detailed discussion of this collection's performance
|
/// See BTreeMap's documentation for a detailed discussion of this collection's performance
|
||||||
/// benefits and drawbacks.
|
/// benefits and drawbacks.
|
||||||
|
///
|
||||||
|
/// It is a logic error for an item to be modified in such a way that the item's ordering relative
|
||||||
|
/// to any other item, as determined by the `Ord` trait, changes while it is in the set. This is
|
||||||
|
/// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
|
||||||
#[derive(Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
|
#[derive(Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct BTreeSet<T>{
|
pub struct BTreeSet<T>{
|
||||||
|
@ -24,6 +24,11 @@ use core::ops::{Sub, BitOr, BitAnd, BitXor};
|
|||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
/// A specialized set implementation to use enum types.
|
/// A specialized set implementation to use enum types.
|
||||||
|
///
|
||||||
|
/// It is a logic error for an item to be modified in such a way that the transformation of the
|
||||||
|
/// item to or from a `usize`, as determined by the `CLike` trait, changes while the item is in the
|
||||||
|
/// set. This is normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe
|
||||||
|
/// code.
|
||||||
pub struct EnumSet<E> {
|
pub struct EnumSet<E> {
|
||||||
// We must maintain the invariant that no bits are set
|
// We must maintain the invariant that no bits are set
|
||||||
// for which no variant exists
|
// for which no variant exists
|
||||||
|
@ -217,6 +217,11 @@ fn test_resize_policy() {
|
|||||||
/// It is required that the keys implement the `Eq` and `Hash` traits, although
|
/// It is required that the keys implement the `Eq` and `Hash` traits, although
|
||||||
/// this can frequently be achieved by using `#[derive(Eq, Hash)]`.
|
/// this can frequently be achieved by using `#[derive(Eq, Hash)]`.
|
||||||
///
|
///
|
||||||
|
/// It is a logic error for a key to be modified in such a way that the key's
|
||||||
|
/// hash, as determined by the `Hash` trait, or its equality, as determined by
|
||||||
|
/// the `Eq` trait, changes while it is in the map. This is normally only
|
||||||
|
/// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
|
||||||
|
///
|
||||||
/// Relevant papers/articles:
|
/// Relevant papers/articles:
|
||||||
///
|
///
|
||||||
/// 1. Pedro Celis. ["Robin Hood Hashing"](https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf)
|
/// 1. Pedro Celis. ["Robin Hood Hashing"](https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf)
|
||||||
|
@ -38,6 +38,12 @@ use super::state::HashState;
|
|||||||
/// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
|
/// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
|
||||||
/// requires that the elements implement the `Eq` and `Hash` traits.
|
/// requires that the elements implement the `Eq` and `Hash` traits.
|
||||||
///
|
///
|
||||||
|
/// It is a logic error for an item to be modified in such a way that the
|
||||||
|
/// item's hash, as determined by the `Hash` trait, or its equality, as
|
||||||
|
/// determined by the `Eq` trait, changes while it is in the set. This is
|
||||||
|
/// normally only possible through `Cell`, `RefCell`, global state, I/O, or
|
||||||
|
/// unsafe code.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
Loading…
Reference in New Issue
Block a user