5 // This software may be used and distributed according to the terms of the |
5 // This software may be used and distributed according to the terms of the |
6 // GNU General Public License version 2 or any later version. |
6 // GNU General Public License version 2 or any later version. |
7 |
7 |
8 use crate::cindex; |
8 use crate::cindex; |
9 use cpython::{ |
9 use cpython::{ |
10 ObjectProtocol, PyClone, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, PythonObject, |
10 ObjectProtocol, PyClone, PyDict, PyModule, PyObject, PyResult, PyTuple, |
11 ToPyObject, |
11 Python, PythonObject, ToPyObject, |
12 }; |
12 }; |
13 use hg::Revision; |
13 use hg::Revision; |
14 use std::cell::RefCell; |
14 use std::cell::RefCell; |
15 |
15 |
16 /// Return a Struct implementing the Graph trait |
16 /// Return a Struct implementing the Graph trait |
17 pub(crate) fn pyindex_to_graph(py: Python, index: PyObject) -> PyResult<cindex::Index> { |
17 pub(crate) fn pyindex_to_graph( |
|
18 py: Python, |
|
19 index: PyObject, |
|
20 ) -> PyResult<cindex::Index> { |
18 match index.extract::<MixedIndex>(py) { |
21 match index.extract::<MixedIndex>(py) { |
19 Ok(midx) => Ok(midx.clone_cindex(py)), |
22 Ok(midx) => Ok(midx.clone_cindex(py)), |
20 Err(_) => cindex::Index::new(py, index), |
23 Err(_) => cindex::Index::new(py, index), |
21 } |
24 } |
22 } |
25 } |