File: big-result.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (61 lines) | stat: -rw-r--r-- 1,385 bytes parent folder | download | duplicates (6)
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
55
56
57
58
59
60
61
#![feature(concat_idents)]
#![allow(nonstandard_style)]
/// Generate 250 items that all match the query, starting with the longest.
/// Those long items should be dropped from the result set, and the short ones
/// should be shown instead.
macro_rules! generate {
    ([$($x:ident),+], $y:tt, $z:tt) => {
        $(
            generate!(@ $x, $y, $z);
        )+
    };
    (@ $x:ident , [$($y:ident),+], $z:tt) => {
        pub struct $x;
        $(
            generate!(@@ $x, $y, $z);
        )+
    };
    (@@ $x:ident , $y:ident, [$($z:ident: $zt:ident),+]) => {
        impl $y {
            pub fn $x($($z: $zt,)+) {}
        }
    }
}

pub struct First;
pub struct Second;
pub struct Third;
pub struct Fourth;
pub struct Fifth;

generate!(
    [a, b, c, d, e],
    [a, b, c, d, e, f, g, h, i, j],
    [a: First, b: Second, c: Third, d: Fourth, e: Fifth]
);

generate!(
    [f, g, h, i, j],
    [a, b, c, d, e, f, g, h, i, j],
    [a: First, b: Second, c: Third, d: Fourth]
);

generate!(
    [k, l, m, n, o],
    [a, b, c, d, e, f, g, h, i, j],
    [a: First, b: Second, c: Third]
);

generate!(
    // reverse it, just to make sure they're alphabetized
    // in the result set when all else is equal
    [t, s, r, q, p],
    [a, b, c, d, e, f, g, h, i, j],
    [a: First, b: Second]
);

generate!(
    [u, v, w, x, y],
    [a, b, c, d, e, f, g, h, i, j],
    [a: First]
);