mod.rs.html -- source
Description: Source to the Rust file `library/alloc/src/collections/btree/mod.rs`.
Keywords: rust, rustlang, rust-lang

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54

    pub mod map;
    mod navigate;
    mod node;
    mod search;
    pub mod set;

    #[doc(hidden)]
    trait Recover<Q: ?Sized> {
        type Key;

        fn get(&self, key: &Q) -> Option<&Self::Key>;
        fn take(&mut self, key: &Q) -> Option<Self::Key>;
        fn replace(&mut self, key: Self::Key) -> Option<Self::Key>;
    }

    #[inline(always)]
    pub unsafe fn unwrap_unchecked<T>(val: Option<T>) -> T {
        val.unwrap_or_else(|| {
            if cfg!(debug_assertions) {
                panic!("'unchecked' unwrap on None in BTreeMap");
            } else {
                unsafe {
                    core::intrinsics::unreachable();
                }
            }
        })
    }

    #[cfg(test)]
    /// XorShiftRng
    struct DeterministicRng {
        x: u32,
        y: u32,
        z: u32,
        w: u32,
    }

    #[cfg(test)]
    impl DeterministicRng {
        fn new() -> Self {
            DeterministicRng { x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, w: 0x113ba7bb }
        }

        fn next(&mut self) -> u32 {
            let x = self.x;
            let t = x ^ (x << 11);
            self.x = self.y;
            self.y = self.z;
            self.z = self.w;
            let w_ = self.w;
            self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8));
            self.w
        }
    }