#match #maintained #longer #eq #prelude #no-core

yanked match-eq

This crate is no longer maintained

0.2.4 Jun 11, 2021
0.2.3 May 7, 2021
0.2.1 Mar 23, 2021
0.1.5 Mar 10, 2021
0.1.4 Feb 26, 2021

#21 in #eq

MPL-2.0 license

15KB
303 lines

This project is no longer maintained.


lib.rs:

A match-like macro that uses PartialEq to "match" each "patten".

Crate feature

  • no-core: Make this crate #![no_core].

    #![no_core] example

    #![feature(no_core, lang_items, start)] #![no_core]

    #[cfg_attr(not(windows), link(name = "c"))] #[cfg_attr(windows, link(name = "msvcrt"))] extern "C" {}

    use match_eq::prelude::*;

    #[lang = "sized"] trait Sized {}

    #[lang = "copy"] trait Copy {}

    impl Copy for i32 {}

    #[lang = "receiver"] trait Receiver {}

    impl<T: ?Sized> Receiver for &T {}

    #[lang = "eh_personality"] fn eh_personality() -> ! { loop {} }

    #[lang = "eq"] trait CustomPartialEq { fn eq(&self, _: &T) -> bool; }

    impl CustomPartialEq for i32 { fn eq(&self, _: &i32) -> bool { loop {} } }

    #[start] fn main(_: isize, _: *const *const u8) -> isize { match_eq!(1 => { 1, 2 => if matches_eq!(3, 3, 4) { if matches_eq!(5, 6, 7) { 1 } else { 0 } } else { 1 }, _ => 1, }) }

    </details>
    
    

Example

use std::ffi::{OsStr, OsString};

assert_eq!(
    match_eq!(OsString::from("🎉") => {
        "🎃" => 0,
        "🚀", "🎉" => -1,
        s = OsStr::new("🎉") => {
            drop::<OsString>(s);
            -2
        }
        ref s = "🎉", OsStr::new("🚀") => {
            let _: &OsString = s;
            -3
        }
        _ = "🎉" => unreachable!(),
        _ => -5,
    }),
    -1
);

No runtime deps

Features