Macro polonius_the_crab::polonius
source · [−]macro_rules! polonius {
(
$(
<
$( $($lt:lifetime),+ $(,)? )?
$( $($T:ident),+ $(,)? )?
>
)?
|$var:ident| -> $Ret:ty $body:block
) => { ... };
}
Expand description
Convenient entry-point to this crate’s logic.
Usage
use ::polonius_the_crab::prelude::*;
let mut a_mut_binding: &mut _ = // …
// the lifetime placeholder has to be
// named `'polonius` !!
// vvvvvvvvv
let x = polonius!(|a_mut_binding| -> SomeRetType<'polonius> {
let some_dependent_type = stuff(a_mut_binding);
if some_cond() {
polonius_return!(some_dependent_type);
}
if some_other_cond() {
polonius_break!(42);
unreachable!();
}
42
});
assert_eq!(x, 42);
stuff(a_mut_binding) // macro gave it back
// …