Skip to content

Commit

Permalink
this macro isn't public, so docstrings won't work
Browse files Browse the repository at this point in the history
  • Loading branch information
wgreenberg committed Jan 21, 2025
1 parent 3cec4e1 commit fbd85d9
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions lib/src/analysis/util.rs
Original file line number Diff line number Diff line change
@@ -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; };
Expand Down

0 comments on commit fbd85d9

Please sign in to comment.