##// END OF EJS Templates
rust-index: make it possible to clone the struct referencing the C index...
Georges Racinet -
r44462:2728fcb8 default
parent child Browse files
Show More
@@ -88,6 +88,15 b' impl Clone for Index {'
88 88 }
89 89 }
90 90
91 impl PyClone for Index {
92 fn clone_ref(&self, py: Python) -> Self {
93 Index {
94 index: self.index.clone_ref(py),
95 capi: self.capi,
96 }
97 }
98 }
99
91 100 impl Graph for Index {
92 101 /// wrap a call to the C extern parents function
93 102 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {
@@ -7,17 +7,14 b''
7 7
8 8 use crate::cindex;
9 9 use cpython::{
10 ObjectProtocol, PyDict, PyModule, PyObject, PyResult, PyTuple, Python,
11 PythonObject, ToPyObject,
10 ObjectProtocol, PyClone, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, PythonObject,
11 ToPyObject,
12 12 };
13 13 use hg::Revision;
14 14 use std::cell::RefCell;
15 15
16 16 /// Return a Struct implementing the Graph trait
17 pub(crate) fn pyindex_to_graph(
18 py: Python,
19 index: PyObject,
20 ) -> PyResult<cindex::Index> {
17 pub(crate) fn pyindex_to_graph(py: Python, index: PyObject) -> PyResult<cindex::Index> {
21 18 cindex::Index::new(py, index)
22 19 }
23 20
@@ -198,6 +195,10 b' impl MixedIndex {'
198 195 .inner()
199 196 .call_method(py, name, args, kwargs)
200 197 }
198
199 pub fn clone_cindex(&self, py: Python) -> cindex::Index {
200 self.cindex(py).borrow().clone_ref(py)
201 }
201 202 }
202 203
203 204 /// Create the module, with __package__ given from parent
General Comments 0
You need to be logged in to leave comments. Login now