match-eq 0.2.4

This crate is no longer maintained.
Documentation

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

Crate feature

#![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 match_eq::prelude::*;

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

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