(py: Python, obj: &PyObject)
| 278 | } |
| 279 | |
| 280 | pub(crate) fn extract_buffer_or_sequence<T>(py: Python, obj: &PyObject) -> PyResult<Vec<T>> |
| 281 | where |
| 282 | for<'a> T: FromPyObject<'a> + buffer::Element + Copy, |
| 283 | { |
| 284 | // first try buffer protocol |
| 285 | if let Ok(buf) = buffer::PyBuffer::get(py, obj) { |
| 286 | if buf.dimensions() == 1 { |
| 287 | if let Ok(v) = buf.to_vec::<T>(py) { |
| 288 | buf.release_ref(py); |
| 289 | return Ok(v); |
| 290 | } |
| 291 | } |
| 292 | buf.release_ref(py); |
| 293 | } |
| 294 | // fall back to sequence protocol |
| 295 | extract_sequence(py, obj) |
| 296 | } |
| 297 | |
| 298 | fn extract_sequence<T>(py: Python, obj: &PyObject) -> PyResult<Vec<T>> |
| 299 | where |
no test coverage detected