Skip to content

Commit c6bebae

Browse files
committed
Clippy
1 parent 6a3e38d commit c6bebae

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

vm/src/builtins.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,8 @@ fn builtin_max(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
380380

381381
if candidates.is_empty() {
382382
let default = args.get_optional_kwarg("default");
383-
if default.is_none() {
384-
return Err(vm.new_value_error("max() arg is an empty sequence".to_string()));
385-
} else {
386-
return Ok(default.unwrap());
387-
}
383+
return default
384+
.ok_or_else(|| vm.new_value_error("max() arg is an empty sequence".to_string()));
388385
}
389386

390387
let key_func = args.get_optional_kwarg("key");
@@ -429,11 +426,8 @@ fn builtin_min(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
429426

430427
if candidates.is_empty() {
431428
let default = args.get_optional_kwarg("default");
432-
if default.is_none() {
433-
return Err(vm.new_value_error("min() arg is an empty sequence".to_string()));
434-
} else {
435-
return Ok(default.unwrap());
436-
}
429+
return default
430+
.ok_or_else(|| vm.new_value_error("min() arg is an empty sequence".to_string()));
437431
}
438432

439433
let key_func = args.get_optional_kwarg("key");

vm/src/obj/objbytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl PyBytesRef {
509509
}
510510
}
511511
None => {
512-
if replacing_char.is_none() {
512+
if replacing_char.is_some() {
513513
decode_content.push(replacing_char.unwrap())
514514
}
515515
}

vm/src/obj/objrange.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -354,19 +354,15 @@ impl PyRange {
354354
} else {
355355
tmp.clone()
356356
}
357-
} else {
358-
if slice_start > upper_bound {
359-
upper_bound.clone()
360-
} else {
361-
slice_start.clone()
362-
}
363-
}
364-
} else {
365-
if negative_step {
357+
} else if slice_start > upper_bound {
366358
upper_bound.clone()
367359
} else {
368-
lower_bound.clone()
360+
slice_start.clone()
369361
}
362+
} else if negative_step {
363+
upper_bound.clone()
364+
} else {
365+
lower_bound.clone()
370366
};
371367

372368
let substop = if let Some(slice_stop) = slice.stop_index(vm)? {
@@ -377,19 +373,15 @@ impl PyRange {
377373
} else {
378374
tmp.clone()
379375
}
376+
} else if slice_stop > upper_bound {
377+
upper_bound.clone()
380378
} else {
381-
if slice_stop > upper_bound {
382-
upper_bound.clone()
383-
} else {
384-
slice_stop.clone()
385-
}
379+
slice_stop.clone()
386380
}
381+
} else if negative_step {
382+
lower_bound.clone()
387383
} else {
388-
if negative_step {
389-
lower_bound.clone()
390-
} else {
391-
upper_bound.clone()
392-
}
384+
upper_bound.clone()
393385
};
394386

395387
let step = range_step * &substep;

0 commit comments

Comments
 (0)