ChristopherBiscardi / advent-of-code

236 stars 47 forks source link

see what removing then_some looks like #20

Closed ChristopherBiscardi closed 10 months ago

ChristopherBiscardi commented 10 months ago

A temporary pull request to see what addressing the clippy lint filter_map_bool_then looks like.

The original issue that motivates the clippy lint seems like it is motivated not by then_some usage, but rather by a large nested computation that wasn't abstracted into a function. The lint itself ignores this and places the burden on any then_some usage, which I think is a miss for the original issue. However, as the original issue doesn't contain the original code that prompted the lint in the first place, its hard to say one way or the other.

In day 06 this replacement seems ok, but in other similar days like day 11 it results in multiple closures where some arguments are ignored. First the first argument, then the second. Day 07 in particular moves from being a single-line to being two closures that ignore different parts of the input.

Day 03 in particular feels like I'd be bending over backwards to satisfy the lint, with the result ending up being multiple filter, map, and filter_map calls.

In none of the cases is the issue that motivated the original lint used. There are no highly-complex functions that use "a dozen lines" (language used in the original issue), so I don't think I'm going to follow this style lint here. Luckily the lint doesn't even actually catch the use cases here, so its not even something that needs to be allow'd.