Keep old 2G downgrade analyzer

This commit is contained in:
Will Greenberg
2025-01-17 13:31:50 -08:00
committed by Cooper Quintin
parent 28b0f409db
commit 30323b8329
5 changed files with 114 additions and 3 deletions

View File

@@ -1,7 +1,34 @@
/// Unpacks a pattern, or returns None.
///
/// # Examples
/// Suppose you've got some highly nested enum:
/// ```
/// enum Foo {
/// A(Bar),
/// B,
/// }
///
/// enum Baz {
/// C(Bang)
/// }
///
/// struct Bang;
/// ```
///
/// You can use `unpack!` to unroll it like this:
/// ```
/// fn get_bang(foo: Foo) -> Option<Bang> {
/// unpack!(Foo::A(bar) = foo);
/// unpack!(Baz::C(bang) = bar);
/// bang
/// }
/// ```
macro_rules! unpack {
($pat:pat = $val:expr) => {
let $pat = $val else { return None; };
};
}
// this is apparently how you make a macro publicly usable from this module
pub(crate) use unpack;