mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-27 16:09:58 -07:00
Keep old 2G downgrade analyzer
This commit is contained in:
committed by
Cooper Quintin
parent
28b0f409db
commit
30323b8329
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user