Debian Codegraph @

tests/equivalent_trait.rs

raw symbols SCIP
1 use ordermaprust-analyzer cargo ordermap 1.2.0 crate/::Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#;
2 use ordermaprust-analyzer cargo ordermap 1.2.0 crate/::ordermaprust-analyzer cargo ordermap 1.2.0 macros/ordermap!;
3
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#;
5
6 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
7 pub struct Pairrust-analyzer cargo ordermap 1.2.0 Pair#<A, B>(pub A, pub B);
8
9 impl<A, B, C, D> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<(A, B)> for Pairrust-analyzer cargo ordermap 1.2.0 Pair#<C, D>
10 where
11 C: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<A>,
12 D: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<B>,
13 {
14 fn eqrust-analyzer cargo ordermap 1.2.0 impl#[`Pair<C, D>`][`PartialEq<(A, B)>`]eq().(&self, rhs: &(A, B)) -> bool {
15 self.0rust-analyzer cargo ordermap 1.2.0 Pair#0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().rhs.0 && self.1rust-analyzer cargo ordermap 1.2.0 Pair#1. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().rhs.1
16 }
17 }
18
19 impl<A, B, X> Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#<X> for Pairrust-analyzer cargo ordermap 1.2.0 Pair#<A, B>
20 where
21 Pairrust-analyzer cargo ordermap 1.2.0 Pair#<A, B>: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<X>,
22 A: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#,
23 B: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#,
24 {
25 fn equivalentrust-analyzer cargo ordermap 1.2.0 impl#[`Pair<A, B>`][`Equivalent<X>`]equivalent().(&self, other: &X) -> bool {
26 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().other
27 }
28 }
29
30 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
31 fn test_lookuprust-analyzer cargo ordermap 1.2.0 test_lookup().() {
32 let s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().;
33 let map = ordermaprust-analyzer cargo ordermap 1.2.0 macros/ordermap!! {
34 (s("a"), s("b")) => 1,
35 (s("a"), s("x")) => 2,
36 };
37
38 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(map.contains_keyrust-analyzer cargo ordermap 1.2.0 map/impl#[`OrderMap<K, V, S>`]contains_key().(&Pairrust-analyzer cargo ordermap 1.2.0 Pair#("a", "b")));
39 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().map.contains_keyrust-analyzer cargo ordermap 1.2.0 map/impl#[`OrderMap<K, V, S>`]contains_key().(&Pairrust-analyzer cargo ordermap 1.2.0 Pair#("b", "a")));
40 }
41
42 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
43 fn test_string_strrust-analyzer cargo ordermap 1.2.0 test_string_str().() {
44 let s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().;
45 let mut map = ordermaprust-analyzer cargo ordermap 1.2.0 macros/ordermap!! {
46 s("a") => 1, s("b") => 2,
47 s("x") => 3, s("y") => 4,
48 };
49
50 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(map.contains_keyrust-analyzer cargo ordermap 1.2.0 map/impl#[`OrderMap<K, V, S>`]contains_key().("a"));
51 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().map.contains_keyrust-analyzer cargo ordermap 1.2.0 map/impl#[`OrderMap<K, V, S>`]contains_key().("z"));
52 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.swap_removerust-analyzer cargo ordermap 1.2.0 map/impl#[`OrderMap<K, V, S>`]swap_remove().("b"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2));
53 }