Skip to content

Commit

Permalink
Fix clippy errors (use intead of )
Browse files Browse the repository at this point in the history
  • Loading branch information
dmidem committed Sep 15, 2023
1 parent 75a278d commit bb2d38c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ impl Builder {
.cloned()
.unwrap();
(num_actions < MIN_ACTIONS)
.then(|| MIN_ACTIONS - num_actions)
.then_some(MIN_ACTIONS - num_actions)
.unwrap_or(0)

Check warning on line 469 in src/builder.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`

warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> src/builder.rs:467:9 | 467 | / (num_actions < MIN_ACTIONS) 468 | | .then_some(MIN_ACTIONS - num_actions) 469 | | .unwrap_or(0) | |_________________________^ help: try: `if (num_actions < MIN_ACTIONS) { MIN_ACTIONS - num_actions } else { 0 }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else = note: `#[warn(clippy::obfuscated_if_else)]` on by default

Check warning on line 469 in src/builder.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`

warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> src/builder.rs:467:9 | 467 | / (num_actions < MIN_ACTIONS) 468 | | .then_some(MIN_ACTIONS - num_actions) 469 | | .unwrap_or(0) | |_________________________^ help: try: `if (num_actions < MIN_ACTIONS) { MIN_ACTIONS - num_actions } else { 0 }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else = note: `#[warn(clippy::obfuscated_if_else)]` on by default

Check failure on line 469 in src/builder.rs

View workflow job for this annotation

GitHub Actions / Clippy (1.65.0)

use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`

error: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> src/builder.rs:467:9 | 467 | / (num_actions < MIN_ACTIONS) 468 | | .then_some(MIN_ACTIONS - num_actions) 469 | | .unwrap_or(0) | |_________________________^ help: try: `if (num_actions < MIN_ACTIONS) { MIN_ACTIONS - num_actions } else { 0 }` | = note: `-D clippy::obfuscated-if-else` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else

Check failure on line 469 in src/builder.rs

View workflow job for this annotation

GitHub Actions / Clippy (1.65.0)

use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`

error: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> src/builder.rs:467:9 | 467 | / (num_actions < MIN_ACTIONS) 468 | | .then_some(MIN_ACTIONS - num_actions) 469 | | .unwrap_or(0) | |_________________________^ help: try: `if (num_actions < MIN_ACTIONS) { MIN_ACTIONS - num_actions } else { 0 }` | = note: `-D clippy::obfuscated-if-else` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
}

Expand Down
4 changes: 2 additions & 2 deletions src/issuance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl IssueAction {
// All assets should be derived correctly
note.asset()
.eq(&issue_asset)
.then(|| ())
.then_some(())
.ok_or(IssueBundleIkMismatchAssetBase)?;

// The total amount should not overflow
Expand All @@ -181,7 +181,7 @@ impl IssueAction {

/// Serialize `finalize` flag to a byte
pub fn flags(&self) -> u8 {
self.finalize.then(|| 0b0000_0001).unwrap_or(0b0000_0000)
self.finalize.then_some(0b0000_0001).unwrap_or(0b0000_0000)

Check warning on line 184 in src/issuance.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`

warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> src/issuance.rs:184:9 | 184 | self.finalize.then_some(0b0000_0001).unwrap_or(0b0000_0000) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if self.finalize { 0b0000_0001 } else { 0b0000_0000 }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else

Check warning on line 184 in src/issuance.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`

warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> src/issuance.rs:184:9 | 184 | self.finalize.then_some(0b0000_0001).unwrap_or(0b0000_0000) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if self.finalize { 0b0000_0001 } else { 0b0000_0000 }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else

Check failure on line 184 in src/issuance.rs

View workflow job for this annotation

GitHub Actions / Clippy (1.65.0)

use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`

error: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> src/issuance.rs:184:9 | 184 | self.finalize.then_some(0b0000_0001).unwrap_or(0b0000_0000) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if self.finalize { 0b0000_0001 } else { 0b0000_0000 }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else

Check failure on line 184 in src/issuance.rs

View workflow job for this annotation

GitHub Actions / Clippy (1.65.0)

use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`

error: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> src/issuance.rs:184:9 | 184 | self.finalize.then_some(0b0000_0001).unwrap_or(0b0000_0000) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if self.finalize { 0b0000_0001 } else { 0b0000_0000 }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/supply_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl SupplyInfo {
finalization_set.extend(
self.assets
.iter()
.filter_map(|(asset, supply)| supply.is_finalized.then(|| asset)),
.filter_map(|(asset, supply)| supply.is_finalized.then_some(asset)),
);
}
}
Expand Down

0 comments on commit bb2d38c

Please sign in to comment.