We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a0430c5 commit f9413a7Copy full SHA for f9413a7
crates/processing_pyo3/src/color.rs
@@ -388,7 +388,8 @@ impl PyColor {
388
fn __getitem__(&self, idx: isize) -> PyResult<f32> {
389
let c = components(&self.0);
390
let idx = if idx < 0 { 4 + idx } else { idx };
391
- if idx < 0 || idx >= 4 {
+
392
+ if !(0..4).contains(&idx) {
393
return Err(PyTypeError::new_err("index out of range"));
394
}
395
Ok(c[idx as usize])
@@ -429,7 +430,7 @@ pub(crate) fn extract_color(args: &Bound<'_, PyTuple>) -> PyResult<Color> {
429
430
431
fn parse_hex(s: &str) -> PyResult<Color> {
432
Srgba::hex(s)
- .map(|srgba| Color::Srgba(srgba))
433
+ .map(Color::Srgba)
434
.map_err(|e| PyTypeError::new_err(format!("invalid hex color: {e}")))
435
436
0 commit comments