Skip to main content

litcheck_core/
lib.rs

1/// This is an implementation of `std::assert_matches::assert_matches`
2/// so it can be removed when that feature stabilizes upstream
3#[macro_export]
4macro_rules! assert_matches {
5    ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
6        match $left {
7            $( $pattern )|+ $( if $guard )? => {}
8            ref left_val => {
9                panic!(r#"
10assertion failed: `(left matches right)`
11    left: `{:?}`,
12    right: `{}`"#, left_val, stringify!($($pattern)|+ $(if $guard)?));
13            }
14        }
15    };
16
17    ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )?, $msg:literal $(,)?) => {
18        match $left {
19            $( $pattern )|+ $( if $guard )? => {}
20            ref left_val => {
21                panic!(concat!(r#"
22assertion failed: `(left matches right)`
23    left: `{:?}`,
24    right: `{}`
25"#, $msg), left_val, stringify!($($pattern)|+ $(if $guard)?));
26            }
27        }
28    };
29
30    ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )?, $msg:literal, $($arg:tt)+) => {
31        match $left {
32            $( $pattern )|+ $( if $guard )? => {}
33            ref left_val => {
34                panic!(concat!(r#"
35assertion failed: `(left matches right)`
36    left: `{:?}`,
37    right: `{}`
38"#, $msg), left_val, stringify!($($pattern)|+ $(if $guard)?), $($arg)+);
39            }
40        }
41    }
42}
43
44pub mod diagnostics;
45pub mod fs;
46mod input;
47pub mod range;
48pub mod reporting;
49pub mod symbol;
50pub mod text;
51pub mod variables;
52
53pub use self::{
54    input::Input,
55    symbol::{Symbol, symbols},
56};
57
58pub type StaticCow<T> = std::borrow::Cow<'static, T>;