diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 787403e97..e19707c3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,7 @@ jobs: with: profile: minimal toolchain: 1.41.1 + default: true - name: Install maturin, poetry, and toml run: pip install maturin poetry toml - name: Create an isolated example directory diff --git a/src/convert.rs b/src/convert.rs index 4023db351..ca85c1971 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -62,12 +62,12 @@ where let (strides, dim) = (self.npy_strides(), self.raw_dim()); let orig_ptr = self.as_ptr(); // Element of which size is 0 is not supported, but check it for future changes - let is_empty_or_size0 = self.is_empty() || std::mem::size_of::() == 0; + let is_empty_or_size0 = self.is_empty() || std::mem::size_of::() == 0; let vec = self.into_raw_vec(); let offset = if is_empty_or_size0 { 0 } else { - unsafe { orig_ptr.offset_from(vec.as_ptr()) as usize } + (orig_ptr as usize - vec.as_ptr() as usize) / std::mem::size_of::() }; let mut boxed_slice = vec.into_boxed_slice(); // data_ptr is not always the pointer to the 1st element.