clippy_utils

Function peel_blocks_with_stmt

Source
pub fn peel_blocks_with_stmt<'a>(expr: &'a Expr<'a>) -> &'a Expr<'a>
Expand description

Removes blocks around an expression, only if the block contains just one expression or just one expression statement with a semicolon. Unsafe blocks are not removed.

Examples:

  • {} -> {}
  • { x } -> x
  • { x; } -> x
  • {{ x; }} -> x
  • { x; y } -> { x; y }
  • { unsafe { x } } -> unsafe { x }