This commit is contained in:
Daniel Alley
2019-09-24 00:50:23 -04:00
parent 6a3e38d4da
commit c6bebae462
3 changed files with 18 additions and 32 deletions

View File

@@ -380,11 +380,8 @@ fn builtin_max(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
if candidates.is_empty() {
let default = args.get_optional_kwarg("default");
if default.is_none() {
return Err(vm.new_value_error("max() arg is an empty sequence".to_string()));
} else {
return Ok(default.unwrap());
}
return default
.ok_or_else(|| vm.new_value_error("max() arg is an empty sequence".to_string()));
}
let key_func = args.get_optional_kwarg("key");
@@ -429,11 +426,8 @@ fn builtin_min(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
if candidates.is_empty() {
let default = args.get_optional_kwarg("default");
if default.is_none() {
return Err(vm.new_value_error("min() arg is an empty sequence".to_string()));
} else {
return Ok(default.unwrap());
}
return default
.ok_or_else(|| vm.new_value_error("min() arg is an empty sequence".to_string()));
}
let key_func = args.get_optional_kwarg("key");

View File

@@ -509,7 +509,7 @@ impl PyBytesRef {
}
}
None => {
if replacing_char.is_none() {
if replacing_char.is_some() {
decode_content.push(replacing_char.unwrap())
}
}

View File

@@ -354,19 +354,15 @@ impl PyRange {
} else {
tmp.clone()
}
} else {
if slice_start > upper_bound {
upper_bound.clone()
} else {
slice_start.clone()
}
}
} else {
if negative_step {
} else if slice_start > upper_bound {
upper_bound.clone()
} else {
lower_bound.clone()
slice_start.clone()
}
} else if negative_step {
upper_bound.clone()
} else {
lower_bound.clone()
};
let substop = if let Some(slice_stop) = slice.stop_index(vm)? {
@@ -377,19 +373,15 @@ impl PyRange {
} else {
tmp.clone()
}
} else {
if slice_stop > upper_bound {
upper_bound.clone()
} else {
slice_stop.clone()
}
}
} else {
if negative_step {
lower_bound.clone()
} else {
} else if slice_stop > upper_bound {
upper_bound.clone()
} else {
slice_stop.clone()
}
} else if negative_step {
lower_bound.clone()
} else {
upper_bound.clone()
};
let step = range_step * &substep;