diff --git a/rascaline-c-api/src/calculator.rs b/rascaline-c-api/src/calculator.rs index 8a512f05a..234a2aba0 100644 --- a/rascaline-c-api/src/calculator.rs +++ b/rascaline-c-api/src/calculator.rs @@ -54,14 +54,13 @@ pub unsafe extern fn rascal_calculator(name: *const c_char, parameters: *const c let mut raw = std::ptr::null_mut(); let unwind_wrapper = std::panic::AssertUnwindSafe(&mut raw); let status = catch_unwind(move || { - let unwind_wrapper = unwind_wrapper; - check_pointers!(name, parameters); let name = CStr::from_ptr(name).to_str()?; let parameters = CStr::from_ptr(parameters).to_str()?; let calculator = Calculator::new(name, parameters.to_owned())?; let boxed = Box::new(rascal_calculator_t(calculator)); + let _ = &unwind_wrapper; *unwind_wrapper.0 = Box::into_raw(boxed); Ok(()) }); diff --git a/rascaline-c-api/src/status.rs b/rascaline-c-api/src/status.rs index a861323bc..2dd255a67 100644 --- a/rascaline-c-api/src/status.rs +++ b/rascaline-c-api/src/status.rs @@ -84,7 +84,7 @@ impl From for rascal_status_t { /// the error into `rascal_status_t`. pub fn catch_unwind(function: F) -> rascal_status_t where F: FnOnce() -> Result<(), Error> + UnwindSafe { match std::panic::catch_unwind(function) { - Ok(Ok(_)) => rascal_status_t(RASCAL_SUCCESS), + Ok(Ok(())) => rascal_status_t(RASCAL_SUCCESS), Ok(Err(error)) => error.into(), Err(error) => Error::from(error).into() } diff --git a/rascaline/src/calculators/neighbor_list.rs b/rascaline/src/calculators/neighbor_list.rs index c092b4753..fc19c22cb 100644 --- a/rascaline/src/calculators/neighbor_list.rs +++ b/rascaline/src/calculators/neighbor_list.rs @@ -500,7 +500,7 @@ impl FullNeighborList { system.compute_neighbors(self.cutoff)?; let species = system.species()?; - for pair in system.pairs()?.iter() { + for pair in system.pairs()? { let first_block_i = descriptor.keys().position(&[ species[pair.first].into(), species[pair.second].into() ]); diff --git a/rascaline/src/calculators/soap/spherical_expansion.rs b/rascaline/src/calculators/soap/spherical_expansion.rs index 1601e2f35..b62cfa37d 100644 --- a/rascaline/src/calculators/soap/spherical_expansion.rs +++ b/rascaline/src/calculators/soap/spherical_expansion.rs @@ -189,7 +189,7 @@ impl SphericalExpansion { let neighbor_i = pair.second; result.pair_to_pair_ids.entry((pair.first, pair.second)) - .or_insert_with(Vec::new) + .or_default() .push(pair_id); let species_neighbor_i = result.species_mapping[&species[neighbor_i]]; @@ -253,7 +253,7 @@ impl SphericalExpansion { let neighbor_i = pair.first; result.pair_to_pair_ids.entry((pair.second, pair.first)) - .or_insert_with(Vec::new) + .or_default() .push(pair_id);