Skip to content

Instantly share code, notes, and snippets.

@iliekturtles
Created May 10, 2018 17:14
Show Gist options
  • Save iliekturtles/1ca45b239c7133cdc259d5089535bc87 to your computer and use it in GitHub Desktop.
Save iliekturtles/1ca45b239c7133cdc259d5089535bc87 to your computer and use it in GitHub Desktop.
pub struct S1; pub struct S2; pub struct S3; pub struct S4; pub struct S5; pub struct S6;
pub struct S7; pub struct S8; pub struct S9; pub struct S10; pub struct S11; pub struct S12;
pub struct S13; pub struct S14; pub struct S15; pub struct S16; pub struct S17; pub struct S18;
pub struct S19; pub struct S20; pub struct S21; pub struct S22; pub struct S23; pub struct S24;
pub struct S25; pub struct S26; pub struct S27; pub struct S28; pub struct S29; pub struct S30;
pub struct S31; pub struct S32; pub struct S33; pub struct S34; pub struct S35; pub struct S36;
pub struct S37; pub struct S38; pub struct S39; pub struct S40; pub struct S41; pub struct S42;
pub struct S43; pub struct S44; pub struct S45; pub struct S46; pub struct S47; pub struct S48;
pub struct S49; pub struct S50; pub struct S51; pub struct S52; pub struct S53; pub struct S54;
pub struct S55; pub struct S56; pub struct S57; pub struct S58; pub struct S59; pub struct S60;
pub struct S61; pub struct S62; pub struct S63; pub struct S64; pub struct S65; pub struct S66;
pub struct S67; pub struct S68; pub struct S69; pub struct S70; pub struct S71; pub struct S72;
pub struct S73; pub struct S74; pub struct S75; pub struct S76; pub struct S77; pub struct S78;
pub struct S79; pub struct S80; pub struct S81; pub struct S82; pub struct S83; pub struct S84;
pub struct S85; pub struct S86; pub struct S87; pub struct S88; pub struct S89; pub struct S90;
pub struct S91; pub struct S92; pub struct S93; pub struct S94; pub struct S95; pub struct S96;
pub struct S97; pub struct S98; pub struct S99; pub struct S100; pub struct S101; pub struct S102;
pub struct S103; pub struct S104; pub struct S105; pub struct S106; pub struct S107;
pub struct S108; pub struct S109; pub struct S110; pub struct S111; pub struct S112;
pub struct S113; pub struct S114; pub struct S115; pub struct S116; pub struct S117;
pub struct S118; pub struct S119; pub struct S120; pub struct S121; pub struct S122;
pub struct S123; pub struct S124; pub struct S125; pub struct S126; pub struct S127;
pub struct S128; pub struct S129; pub struct S130; pub struct S131; pub struct S132;
pub struct S133; pub struct S134; pub struct S135; pub struct S136; pub struct S137;
pub struct S138; pub struct S139; pub struct S140; pub struct S141; pub struct S142;
pub struct S143; pub struct S144; pub struct S145; pub struct S146; pub struct S147;
pub struct S148; pub struct S149; pub struct S150; pub struct S151; pub struct S152;
pub struct S153; pub struct S154; pub struct S155; pub struct S156; pub struct S157;
pub struct S158; pub struct S159; pub struct S160;
pub trait T<I>
{
fn t(I) -> Self;
}
macro_rules! impl_from {
($($s:ident),+) => {
$(
#[cfg(any(feature = "I1", feature = "I2", feature = "I3", feature = "I4", feature = "I5"))]
impl T<V> for $s {
fn t(_v: V) -> $s {
$s
}
}
#[cfg(any(feature = "I2", feature = "I3", feature = "I4", feature = "I5"))]
impl T<(V, i32)> for $s {
fn t(_v: (V, i32)) -> $s {
$s
}
}
#[cfg(any(feature = "I3", feature = "I4", feature = "I5"))]
impl T<(V, i32, i32)> for $s {
fn t(_v: (V, i32, i32)) -> $s {
$s
}
}
#[cfg(any(feature = "I4", feature = "I5"))]
impl T<(V, i32, i32, i32)> for $s {
fn t(_v: (V, i32, i32, i32)) -> $s {
$s
}
}
#[cfg(any(feature = "I5"))]
impl T<(V, i32, i32, i32, i32)> for $s {
fn t(_v: (V, i32, i32, i32, i32)) -> $s {
$s
}
}
)+
};
}
macro_rules! impl_mod {
($($t:ident),+) => {
$(mod $t {
#[allow(dead_code)]
#[cfg(feature = "pub")]
pub type V = $t;
#[cfg(feature = "priv")]
type V = $t;
pub use ::*;
#[cfg(any(feature = "T1", feature = "T2", feature = "T3", feature = "T4", feature = "T5", feature = "T6", feature = "T7", feature = "T8"))]
impl_from!(S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16, S17, S18, S19, S20);
#[cfg(any(feature = "T2", feature = "T3", feature = "T4", feature = "T5", feature = "T6", feature = "T7", feature = "T8"))]
impl_from!(S21, S22, S23, S24, S25, S26, S27, S28, S29, S30, S31, S32, S33, S34, S35, S36, S37, S38, S39, S40);
#[cfg(any(feature = "T3", feature = "T4", feature = "T5", feature = "T6", feature = "T7", feature = "T8"))]
impl_from!(S41, S42, S43, S44, S45, S46, S47, S48, S49, S50, S51, S52, S53, S54, S55, S56, S57, S58, S59, S60);
#[cfg(any(feature = "T4", feature = "T5", feature = "T6", feature = "T7", feature = "T8"))]
impl_from!(S61, S62, S63, S64, S65, S66, S67, S68, S69, S70, S71, S72, S73, S74, S75, S76, S77, S78, S79, S80);
#[cfg(any(feature = "T5", feature = "T6", feature = "T7", feature = "T8"))]
impl_from!(S81, S82, S83, S84, S85, S86, S87, S88, S89, S90, S91, S92, S93, S94, S95, S96, S97, S98, S99, S100);
#[cfg(any(feature = "T6", feature = "T7", feature = "T8"))]
impl_from!(S101, S102, S103, S104, S105, S106, S107, S108, S109, S110, S111, S112, S113, S114, S115, S116, S117, S118, S119, S120);
#[cfg(any(feature = "T7", feature = "T8"))]
impl_from!(S121, S122, S123, S124, S125, S126, S127, S128, S129, S130, S131, S132, S133, S134, S135, S136, S137, S138, S139, S140);
#[cfg(any(feature = "T8"))]
impl_from!(S141, S142, S143, S144, S145, S146, S147, S148, S149, S150, S151, S152, S153, S154, S155, S156, S157, S158, S159, S160);
})+
};
}
impl_mod!(
bool, char, usize, u8, u16, u32, u64, isize, i8, i16, i32, i64, f32, f64
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment