]> git.lizzy.rs Git - rust.git/blob - library/alloc/src/collections/btree/mod.rs
Auto merge of #75518 - davidtwco:issue-75326-polymorphization-symbol-mangling-v0...
[rust.git] / library / alloc / src / collections / btree / mod.rs
1 pub mod map;
2 mod navigate;
3 mod node;
4 mod search;
5 pub mod set;
6
7 #[doc(hidden)]
8 trait Recover<Q: ?Sized> {
9     type Key;
10
11     fn get(&self, key: &Q) -> Option<&Self::Key>;
12     fn take(&mut self, key: &Q) -> Option<Self::Key>;
13     fn replace(&mut self, key: Self::Key) -> Option<Self::Key>;
14 }
15
16 #[inline(always)]
17 pub unsafe fn unwrap_unchecked<T>(val: Option<T>) -> T {
18     val.unwrap_or_else(|| {
19         if cfg!(debug_assertions) {
20             panic!("'unchecked' unwrap on None in BTreeMap");
21         } else {
22             unsafe {
23                 core::intrinsics::unreachable();
24             }
25         }
26     })
27 }
28
29 #[cfg(test)]
30 /// XorShiftRng
31 struct DeterministicRng {
32     x: u32,
33     y: u32,
34     z: u32,
35     w: u32,
36 }
37
38 #[cfg(test)]
39 impl DeterministicRng {
40     fn new() -> Self {
41         DeterministicRng { x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, w: 0x113ba7bb }
42     }
43
44     fn next(&mut self) -> u32 {
45         let x = self.x;
46         let t = x ^ (x << 11);
47         self.x = self.y;
48         self.y = self.z;
49         self.z = self.w;
50         let w_ = self.w;
51         self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8));
52         self.w
53     }
54 }