From b1472edb77c69ec4d96e38751b68c6b8b5034a88 Mon Sep 17 00:00:00 2001
From: Arthur Carcano <53921575+krtab@users.noreply.github.com>
Date: Sun, 9 May 2021 12:10:56 +0200
Subject: [PATCH] a few rename

---
 cvode-wrap/src/lib.rs     | 12 ++++++------
 cvode-wrap/src/nvector.rs | 15 ++++++++-------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/cvode-wrap/src/lib.rs b/cvode-wrap/src/lib.rs
index d0f1911..1aa421d 100644
--- a/cvode-wrap/src/lib.rs
+++ b/cvode-wrap/src/lib.rs
@@ -10,7 +10,7 @@ use cvode_5_sys::{
 };
 
 mod nvector;
-use nvector::NVectorSerial;
+use nvector::NVectorSerialHeapAlloced;
 
 pub type Realtype = realtype;
 pub type CVector = cvode::N_Vector;
@@ -61,7 +61,7 @@ impl From<NonNull<CvodeMemoryBlock>> for CvodeMemoryBlockNonNullPtr {
 /// See [crate-level](`crate`) documentation for more.
 pub struct Solver<UserData, const N: usize> {
     mem: CvodeMemoryBlockNonNullPtr,
-    y0: NVectorSerial<N>,
+    y0: NVectorSerialHeapAlloced<N>,
     sunmatrix: SUNMatrix,
     linsolver: SUNLinearSolver,
     atol: AbsTolerance<N>,
@@ -138,7 +138,7 @@ fn check_flag_is_succes(flag: c_int, func_id: &'static str) -> Result<()> {
 
 pub enum AbsTolerance<const SIZE: usize> {
     Scalar(Realtype),
-    Vector(NVectorSerial<SIZE>),
+    Vector(NVectorSerialHeapAlloced<SIZE>),
 }
 
 impl<const SIZE: usize> AbsTolerance<SIZE> {
@@ -147,7 +147,7 @@ impl<const SIZE: usize> AbsTolerance<SIZE> {
     }
 
     pub fn vector(atol: &[Realtype; SIZE]) -> Self {
-        let atol = NVectorSerial::new_from(atol);
+        let atol = NVectorSerialHeapAlloced::new_from(atol);
         AbsTolerance::Vector(atol)
     }
 }
@@ -167,7 +167,7 @@ impl<UserData, const N: usize> Solver<UserData, N> {
             let mem_maybenull = unsafe { cvode::CVodeCreate(method as c_int) };
             check_non_null(mem_maybenull as *mut CvodeMemoryBlock, "CVodeCreate")?.into()
         };
-        let y0 = NVectorSerial::new_from(y0);
+        let y0 = NVectorSerialHeapAlloced::new_from(y0);
         let matrix = {
             let matrix = unsafe {
                 cvode_5_sys::sunmatrix_dense::SUNDenseMatrix(
@@ -244,7 +244,7 @@ impl<UserData, const N: usize> Solver<UserData, N> {
             )
         };
         check_flag_is_succes(flag, "CVode")?;
-        Ok((tret, self.y0.as_ref()))
+        Ok((tret, self.y0.as_slice()))
     }
 }
 
diff --git a/cvode-wrap/src/nvector.rs b/cvode-wrap/src/nvector.rs
index 97f70bd..f3e363e 100644
--- a/cvode-wrap/src/nvector.rs
+++ b/cvode-wrap/src/nvector.rs
@@ -2,13 +2,14 @@ use std::{convert::TryInto, intrinsics::transmute, ops::Deref, ptr::NonNull};
 
 use cvode_5_sys::{cvode::realtype, nvector_serial};
 
+
 #[repr(transparent)]
 #[derive(Debug)]
-pub struct NVectorSerial<const SIZE: usize> {
+pub struct NVectorSerialHeapAlloced<const SIZE: usize> {
     inner: NonNull<nvector_serial::_generic_N_Vector>,
 }
 
-impl<const SIZE: usize> Deref for NVectorSerial<SIZE> {
+impl<const SIZE: usize> Deref for NVectorSerialHeapAlloced<SIZE> {
     type Target = nvector_serial::_generic_N_Vector;
 
     fn deref(&self) -> &Self::Target {
@@ -16,12 +17,12 @@ impl<const SIZE: usize> Deref for NVectorSerial<SIZE> {
     }
  }
 
-impl<const SIZE: usize> NVectorSerial<SIZE> {
-    pub fn as_ref(&self) -> &[realtype; SIZE] {
+impl<const SIZE: usize> NVectorSerialHeapAlloced<SIZE> {
+    pub fn as_slice(&self) -> &[realtype; SIZE] {
         unsafe { transmute(nvector_serial::N_VGetArrayPointer_Serial(self.as_raw())) }
     }
 
-    pub fn as_mut(&mut self) -> &mut [realtype; SIZE] {
+    pub fn as_slice_mut(&mut self) -> &mut [realtype; SIZE] {
         unsafe { transmute(nvector_serial::N_VGetArrayPointer_Serial(self.as_raw())) }
     }
 
@@ -34,7 +35,7 @@ impl<const SIZE: usize> NVectorSerial<SIZE> {
 
     pub fn new_from(data: &[realtype; SIZE]) -> Self {
         let mut res = Self::new();
-        res.as_mut().copy_from_slice(data);
+        res.as_slice_mut().copy_from_slice(data);
         res
     }
 
@@ -43,7 +44,7 @@ impl<const SIZE: usize> NVectorSerial<SIZE> {
     }
 }
 
-impl<const SIZE: usize> Drop for NVectorSerial<SIZE> {
+impl<const SIZE: usize> Drop for NVectorSerialHeapAlloced<SIZE> {
     fn drop(&mut self) {
         unsafe { nvector_serial::N_VDestroy(self.as_raw()) }
     }
-- 
GitLab