Description
Replace a boolean variable/parameter with a two-case enum for better readability.
Before:
func configure(animated: Bool) {
if animated {
fadeIn()
} else {
show()
}
}
configure(animated: true)
After:
enum AnimationStyle {
case animated
case immediate
}
func configure(animation: AnimationStyle) {
if animation == .animated {
fadeIn()
} else {
show()
}
}
configure(animation: .animated)
See also: rust-analyzer convert_bool_to_enum
Description
Replace a boolean variable/parameter with a two-case enum for better readability.
Before:
After:
See also: rust-analyzer
convert_bool_to_enum