mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-26 15:39:59 -07:00
this macro isn't public, so docstrings won't work
This commit is contained in:
committed by
Cooper Quintin
parent
da4952e70f
commit
34d87d1fd7
@@ -1,29 +1,27 @@
|
||||
|
||||
/// Unpacks a pattern, or returns None.
|
||||
///
|
||||
/// # Examples
|
||||
/// You can use `unpack!` to unroll highly nested enums like this:
|
||||
/// ```
|
||||
/// use super::util::unpack;
|
||||
///
|
||||
/// enum Foo {
|
||||
/// A(Bar),
|
||||
/// B,
|
||||
/// }
|
||||
///
|
||||
/// enum Bar {
|
||||
/// C(Baz)
|
||||
/// }
|
||||
///
|
||||
/// struct Baz;
|
||||
///
|
||||
/// fn get_bang(foo: Foo) -> Option<Baz> {
|
||||
/// unpack!(Foo::A(bar) = foo);
|
||||
/// unpack!(Bar::C(baz) = bar);
|
||||
/// baz
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
// Unpacks a pattern, or returns None.
|
||||
//
|
||||
// # Examples
|
||||
// You can use `unpack!` to unroll highly nested enums like this:
|
||||
// ```
|
||||
// enum Foo {
|
||||
// A(Bar),
|
||||
// B,
|
||||
// }
|
||||
//
|
||||
// enum Bar {
|
||||
// C(Baz)
|
||||
// }
|
||||
//
|
||||
// struct Baz;
|
||||
//
|
||||
// fn get_bang(foo: Foo) -> Option<Baz> {
|
||||
// unpack!(Foo::A(bar) = foo);
|
||||
// unpack!(Bar::C(baz) = bar);
|
||||
// baz
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
macro_rules! unpack {
|
||||
($pat:pat = $val:expr) => {
|
||||
let $pat = $val else { return None; };
|
||||
|
||||
Reference in New Issue
Block a user