##// END OF EJS Templates
rust: run cargo fmt
Raphaël Gomès -
r43087:6a551a2d default
parent child Browse files
Show More
@@ -31,10 +31,10 b' mod conversion;'
31 31 pub mod ref_sharing;
32 32 pub mod dagops;
33 33 pub mod dirstate;
34 pub mod parsers;
35 34 pub mod discovery;
36 35 pub mod exceptions;
37 36 pub mod filepatterns;
37 pub mod parsers;
38 38
39 39 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| {
40 40 m.add(
@@ -36,9 +36,7 b' pub struct Index {'
36 36
37 37 impl Index {
38 38 pub fn new(index: IndexPtr) -> Self {
39 Index {
40 index: index,
41 }
39 Index { index: index }
42 40 }
43 41 }
44 42
@@ -46,8 +44,13 b' impl Graph for Index {'
46 44 /// wrap a call to the C extern parents function
47 45 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {
48 46 let mut res: [c_int; 2] = [0; 2];
49 let code =
50 unsafe { HgRevlogIndex_GetParents(self.index, rev, &mut res as *mut [c_int; 2]) };
47 let code = unsafe {
48 HgRevlogIndex_GetParents(
49 self.index,
50 rev,
51 &mut res as *mut [c_int; 2],
52 )
53 };
51 54 match code {
52 55 0 => Ok(res),
53 56 _ => Err(GraphError::ParentOutOfRange(rev)),
@@ -98,22 +101,26 b' unsafe fn raw_init<G: Graph>('
98 101
99 102 let slice = slice::from_raw_parts(initrevs, initrevslen);
100 103
101 Box::into_raw(Box::new(match AncestorsIterator::new(
102 graph,
103 slice.into_iter().map(|&r| r as Revision),
104 stoprev as Revision,
105 inclb,
106 ) {
107 Ok(it) => it,
108 Err(_) => {
109 return null_mut();
110 }
111 }))
104 Box::into_raw(Box::new(
105 match AncestorsIterator::new(
106 graph,
107 slice.into_iter().map(|&r| r as Revision),
108 stoprev as Revision,
109 inclb,
110 ) {
111 Ok(it) => it,
112 Err(_) => {
113 return null_mut();
114 }
115 },
116 ))
112 117 }
113 118
114 119 /// Deallocator to be called from C code
115 120 #[no_mangle]
116 pub extern "C" fn rustlazyancestors_drop(raw_iter: *mut AncestorsIterator<Index>) {
121 pub extern "C" fn rustlazyancestors_drop(
122 raw_iter: *mut AncestorsIterator<Index>,
123 ) {
117 124 raw_drop(raw_iter);
118 125 }
119 126
@@ -131,7 +138,9 b' fn raw_drop<G: Graph>(raw_iter: *mut Anc'
131 138 /// it will be up to the C wrapper to convert that back into a Python end of
132 139 /// iteration
133 140 #[no_mangle]
134 pub extern "C" fn rustlazyancestors_next(raw: *mut AncestorsIterator<Index>) -> c_long {
141 pub extern "C" fn rustlazyancestors_next(
142 raw: *mut AncestorsIterator<Index>,
143 ) -> c_long {
135 144 raw_next(raw)
136 145 }
137 146
@@ -227,7 +236,9 b' mod tests {'
227 236 let mut initrevs: Vec<c_long> = vec![11, 13];
228 237 let initrevs_len = initrevs.len();
229 238 let initrevs_ptr = initrevs.as_mut_ptr() as usize;
230 let handler = thread::spawn(move || stub_raw_init(initrevs_len, initrevs_ptr, 0, 1));
239 let handler = thread::spawn(move || {
240 stub_raw_init(initrevs_len, initrevs_ptr, 0, 1)
241 });
231 242 let raw = handler.join().unwrap() as *mut AncestorsIterator<Stub>;
232 243
233 244 assert_eq!(raw_next(raw), 13);
General Comments 0
You need to be logged in to leave comments. Login now