mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-11-04 06:56:14 +00:00 
			
		
		
		
	`concat_idents!` is in the process of being removed, but a few things it is used to test will still be relevant. Migrate these tests to something other than `concat_idents`.
		
			
				
	
	
		
			61 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
#![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]
 | 
						|
);
 |