Closed
Description
🐛 Bug Reports
When reporting a bug, please provide the following information. If this is not a bug report you can just discard this template.
🌍 Environment
- Your operating system and version: Ubuntu 18.04.4
- Your python version: 3.7.5
- How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: virtualenv
- Your rust version (
rustc --version
): rustc 1.43.0-nightly (18c275b42 2020-03-02) - Are you using the latest pyo3 version? Have you tried using latest master (replace
version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
Yes, using latest master
💥 Reproducing
lib.rs
use pyo3::class::PySequenceProtocol;
use pyo3::prelude::*;
use pyo3::{exceptions, PyErr, PyResult};
#[pyclass(module = "test", dict)]
#[derive(Clone, Debug)]
struct Test {
#[pyo3(get, set)]
value: Vec<Option<i64>>,
}
#[pyproto]
impl PySequenceProtocol for Test {
fn __getitem__(&self, idx: isize) -> PyResult<Option<i64>> {
match self.value.get(idx as usize) {
Some(x) => Ok(*x),
None => Err(PyErr::new::<exceptions::IndexError, _>(
"Index out of bounds",
)),
}
}
}
Problem:
"the trait bound std::result::Result<i64, pyo3::err::PyErr>: std::convert::From<std::result::Result<std::option::Option<i64>, pyo3::err::PyErr>>
is not satisfied"
I don't want to convert from std::result::Result<std::option::Option<i64>, pyo3::err::PyErr>
to std::result::Result<i64, pyo3::err::PyErr>
. I want to return an std::result::Result<Option<i64>, pyo3::err::PyErr>