Skip to content

The DCPL branch #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 103 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
16b4b1a
Add DCPL (DatasetCreate) class/builder skeletons
aldanor Jul 21, 2019
16cb14e
Add DCPL::chunk() + tests
aldanor Jul 21, 2019
a52ee7d
Add DCPL::layout() + tests
aldanor Jul 21, 2019
2357aae
Add DCPL::chunk_opts() + tests
aldanor Jul 21, 2019
965061f
Add DCPL::alloc_time() + tests
aldanor Jul 21, 2019
c4d8a66
Add DCPL::all_filters_avail()
aldanor Jul 27, 2019
c2d7a3c
Add DCPL::external() + tests
aldanor Jul 27, 2019
20b13b5
Implement new Filter type for built-in filters
aldanor Jul 24, 2019
1d351a3
Add DCPL::filters() + add filters to DCPL builder
aldanor Aug 16, 2019
42370a3
LZF: add liblzf C sources (from h5py v2.9.0)
aldanor Jul 26, 2019
4b8bab9
LZF: add h5py/liblzf licenses
aldanor Aug 18, 2019
6719b83
LZF: add feature = "lzf", build liblzf
aldanor Jul 26, 2019
9e0441b
LZF: implement LZF filter
aldanor Jul 26, 2019
284e94c
LZF: add LZF support to Filter / DCPL
aldanor Jul 26, 2019
3b2afd0
Blosc: add c-blosc submodule (v1.17.1)
aldanor Jul 27, 2019
1e8ac82
Blosc: add c-blosc license
aldanor Aug 18, 2019
3345a8b
Blosc: add feature = "blosc", build blosc with cmake
aldanor Jul 27, 2019
0e12e7a
Blosc: implement Blosc filter
aldanor Jul 28, 2019
40f1206
Blosc: add Blosc support to Filter / DCPL
aldanor Aug 17, 2019
0604366
Add filters::register_filters()
aldanor Jul 27, 2019
4f967f2
Auto-register all filters on access to globals
aldanor Jul 27, 2019
62bbd39
Implement new Extents type
aldanor Aug 17, 2019
0eebc17
Add tests for Extents
aldanor Aug 17, 2019
27ee854
Implement new Dataspace type
aldanor Aug 17, 2019
2d8502d
Add tests for Dataspace
aldanor Sep 8, 2019
29b3a52
Implement new Selection type
aldanor Oct 4, 2019
b33ac30
Add tests for Selection
aldanor Oct 4, 2019
0c8a52b
Add selection-related methods to Dataspace
aldanor Oct 3, 2019
02a92e1
Replace space::Dataspace with the new Dataspace
aldanor Oct 3, 2019
af0c5c7
Add DCPL::virtual_map() + tests
aldanor Aug 16, 2019
461ab4b
Add filters::{gzip,szip,lzf.blosc}_available()
aldanor Oct 5, 2019
a062b59
Change the way scale-offset filter is represented
aldanor Oct 5, 2019
1e658f5
Add filters::validate_filters()
aldanor Oct 5, 2019
07f7d1a
Re-export plist builders in top-level plist mod
aldanor Oct 7, 2019
bf4d9fe
Implement LCPL (link create) plist/builder
aldanor Oct 7, 2019
dec2eda
Add tests for LCPL plist
aldanor Oct 7, 2019
a016569
DCPL: add VirtualMapping::new()
aldanor Oct 8, 2019
f005b32
Add DynValue/OwnedDynValue (polymorphic value)
aldanor Oct 10, 2019
d5a1097
Add tests for DynValue/OwnedDynValue
aldanor Oct 13, 2019
e07ee22
Fix lzfP.h so it compiles on macOS 10.14
aldanor Jan 6, 2020
0522f4b
Add Object::try_borrow() helper
aldanor Jan 8, 2020
ce5c889
Use Object::try_borrow() in Dataset::new()
aldanor Jan 8, 2020
af5c90d
Add DCPL::obj_track_times() + tests
aldanor Jan 8, 2020
09b249f
Add FCPL::obj_track_times() + tests
aldanor Jan 8, 2020
5524b05
Add DCPL::attr_phase_change() + tests
aldanor Jan 10, 2020
7df58dc
Add FCPL::attr_phase_change() + tests
aldanor Jan 10, 2020
6956c85
Add DCPL::attr_creation_order() + tests
aldanor Jan 10, 2020
5f8a787
Add FCPL::attr_creation_order() + tests
aldanor Jan 10, 2020
e88fce7
Ensure all bitflags have Default impl
aldanor Jan 10, 2020
e1f68cc
DCPL::chunk() takes any Dimension types now
aldanor Jan 10, 2020
e34faf6
Add some extra tests for DCPL::virtual_map()
aldanor Jan 10, 2020
60aff91
Add DCPL::no_chunk() to builder
aldanor Jan 10, 2020
9d81c68
Add DCPL::clear_filters() to builder
aldanor Jan 10, 2020
3b65c90
Add DCPL::fill_time() + tests
aldanor Jan 10, 2020
1fb454c
Impl From<H5Type> for OwnedDynValue
aldanor Jan 11, 2020
e297f1b
Add a few helper methods to OwnedDynValue
aldanor Jan 19, 2020
2161db2
Add DCPL::fill_value() + tests
aldanor Jan 19, 2020
cc0268f
Add .apply() method to all plist builders
aldanor Apr 13, 2020
1f00fbd
Add DatasetCreateBuilder::validate_filters()
aldanor Jan 10, 2020
2587770
DATASET v2 WIP
aldanor Aug 10, 2020
48e75f5
wip
aldanor Aug 11, 2020
f2b20fd
WIP
aldanor Aug 24, 2020
813ab17
Ensure crate compiles in current state
mulimoen Jan 29, 2021
16b24e9
Import blosc and lzf instead of direct bundling
mulimoen Jan 29, 2021
899fe7e
Implement relevant methods on DatasetBuilders
mulimoen Feb 2, 2021
d8b5454
Export builders for docs
mulimoen Feb 2, 2021
042fcc2
Add first compute_chunk_shape implementation
mulimoen Feb 3, 2021
df094cf
Simplify chunk shape for scalar datasets
mulimoen Feb 3, 2021
2b1243d
Skip chunk test for scalar
mulimoen Feb 3, 2021
74864ce
Remove redundant imports
mulimoen Feb 3, 2021
733bffb
Replace str transmute call with str::from_utf8
mulimoen Feb 3, 2021
d2735f9
Fix warnings from clippy lints
mulimoen Feb 4, 2021
7c3452b
Use hdf5 allocator in hdf5-types
mulimoen Feb 4, 2021
41db2ed
Replace dataset with dataset2
mulimoen Feb 6, 2021
9d31c53
Add blosc/lzf docs to docs.rs metadata
mulimoen Feb 6, 2021
160f814
Update README with new builder syntax
mulimoen Feb 7, 2021
1547d1a
Only call H5open/register_filters once
mulimoen Feb 8, 2021
261116e
Use ensure over fail and remove unused dbg prints
mulimoen Feb 8, 2021
1484936
Use dash in feature flag const-generics
mulimoen Feb 8, 2021
f7afc08
Use cfg-if for function selection
mulimoen Feb 8, 2021
935b9c5
Set default chunk size to 64MB
mulimoen Feb 8, 2021
5132792
Replace blosc/lzf git with crates.io
mulimoen Feb 8, 2021
00dfbab
Iterators in extents are now opaque
mulimoen Feb 8, 2021
7294d2a
Replace filters.rs with hl/filters.rs
mulimoen Feb 8, 2021
52766ad
Move mod.rs up one level
mulimoen Feb 9, 2021
fa1d525
Implement From instead of Into
mulimoen Feb 9, 2021
74f6fc7
Reduce scope of variables in container
mulimoen Feb 10, 2021
544eddd
Add space between items
mulimoen Feb 10, 2021
c5a0f60
Suggest compression filter for unlimited dimension
mulimoen Feb 10, 2021
a45c680
Add missing DatasetBuilder create()
mulimoen Feb 11, 2021
3ef15f5
Avoid lazy_static for link_hid
mulimoen Feb 18, 2021
126ad73
Resizable extents with new semantics
mulimoen Feb 25, 2021
158d171
Add entries to CHANGELOG
mulimoen Feb 25, 2021
4c50648
Update CHANGELOG.md
mulimoen Apr 6, 2021
8094d4c
Update dependencies (breaking: ndarray)
mulimoen Apr 6, 2021
d4b5e98
Ignore upper_case_acronyms clippy lint
mulimoen Apr 6, 2021
2449647
Rename h5-alloc feature flag
mulimoen Apr 6, 2021
dee2902
Add version tracker tag
mulimoen Apr 6, 2021
2038cde
Code suggestions from Clippy
mulimoen Apr 6, 2021
2b5f72c
Always use const-generics (MSRV)
mulimoen Apr 6, 2021
092bab3
Update documentation regarding ndarray and impl blocks
mulimoen Apr 7, 2021
09ada50
Add conversion options for DatasetBuilderData
mulimoen Apr 7, 2021
8fdf133
Remove licenses from root
mulimoen Apr 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ jobs:
run: |
[ "${{matrix.mpi}}" != "serial" ] && FEATURES=mpio
cargo test -vv --features="$FEATURES"
- name: Test const generics
if: matrix.rust == 'nightly'
run: cargo test -p hdf5-types --features hdf5-types/const_generics

msi:
name: msi
Expand Down Expand Up @@ -209,6 +206,22 @@ jobs:
- name: Build and test all crates
run: cargo test -vv

msrv:
name: Minimal Supported Rust Version
runs-on: ubuntu-18.04
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
with: {submodules: true}
- name: Install Rust
uses: actions-rs/toolchain@v1
with: {toolchain: 1.51, profile: minimal, override: true}
- name: Build and test all crates
run:
cargo test --workspace -vv --features=hdf5-sys/static --exclude=hdf5-derive

wine:
name: wine
runs-on: ubuntu-latest
Expand Down
59 changes: 59 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,65 @@

## Unreleased

### Added

- Complete rewrite of `DatasetBuilder`; dataset creation API is now different and not
backwards-compatible (however, it integrates all of the new features and is more
flexible and powerful). It is now possible to create and write the datasets in one step.
Refer to the API docs for full reference.
- New `Extents` type matching HDF5 extents types: null (no elements), scalar, simple (fixed
dimensionality); it is used to query and specify shapes of datasets. Extents objects
are convertible from numbers and also tuples, slices and vectors of indices - all of
which can be used whenever extents are required (e.g., when creating a new dataset).
- New `Selection` type and the API around it closely matching HDF5 selection API - this
includes 'all' selection, point-wise selection and hyperslab selection (only 'regular'
hyperslabs are supported - that is, hyperslabs that can be represented as a single
multi-dimensional box some of whose dimensions may be infinite). Selection objects
are convertible from numbers and ranges and tuples and arrays of numbers and ranges;
one can also use `s!` macro from `ndarray` crate. Selections can be provided when
reading and writing slices.
- LZF / Blosc filters have been added, they have to be enabled by `"lzf"` / `"blosc"`
cargo features and depend on `lzf-sys` / `blosc-sys` crates respectively. Blosc filter
is a meta-filter providing multi-threaded access to the best-in-class compression codecs
like Zstd and LZ4 and is recommended to use as a default when compression is critical.
- New `Filter` type to unify all of the filters API; if LZF / Blosc filters are enabled,
this enum also contains the corresponding variants. It is now also possible to provide
user-defined filters with custom filter IDs and parameters.
- Dataset creation property list (DCPL) API is now supported; this provides access to all
of the properties that can be specified at dataset creation time (e.g., layout, chunking,
fill values, external file linking, virtual maps, object time tracking, attribute
creation order, and a few other low-level settings).
- As part of DCPL change, virtual dataset maps (VDS API in HDF5 1.10+) are now supported.
- Link creation property list (LCPL) API is now also wrapped.
- File creation property list (FCPL) API has been extended to include a few previously
missing properties (object time tracking, attribute creation order and few other
low-level settings).
- Added `h5-alloc` feature to `hdf5-types` crate - uses the HDF5 allocator for
varlen types and dynamic values. This may be necessary on platforms where different
allocators may be used in different libraries (e.g. dynamic libraries on Windows),
or if `libhdf5` is compiled with the memchecker option enabled. This option is
force-enabled by default if using a dll version of the library on Windows.
- New `DynValue` type which represents a dynamic self-describing HDF5 object that
also knows how to deallocate itself; it supports all of the HDF5 types including
compound types, strings and arrays.
- Added methods to `Dataset`: `layout`, `dapl`, `access_plist`, `dcpl`, `create_plist`.

### Changed

- `Dataspace` type has been reworked and can be now constructed from an extents object
and sliced with a selection object.
- `Dataset::fill_value` now returns an object of the newly added `DynValue` type; this
object is self-describing and knows how to free itself.
- Automatic chunking now uses a fill-from-back approach instead of the previously
used method which is used in `h5py`.
- Removed `Filters` type (there's now `Filter` that represents a single filter).
- `write_slice`, `read_slice`, `read_slice_1d`, `read_slice_2d` now take any object
convertible to `Selection` (instead of `SliceInfo`).
- `Dataset::chunks` has been renamed to `Dataset::chunk`
- Const generics support (MSRV 1.51): `hdf5-types` now uses const generics for array types,
allowing fixed-size arrays of arbitrary sizes.
- The `ndarray` dependency has been updated to `0.15`.

## 0.7.1

### Added
Expand Down
12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ edition = "2018"
[features]
default = []
mpio = ["mpi-sys", "hdf5-sys/mpio"]
lzf = ["lzf-sys", "errno"]
blosc = ["blosc-sys"]

[workspace]
members = [".", "hdf5-types", "hdf5-derive", "hdf5-sys", "hdf5-src"]
Expand All @@ -24,21 +26,25 @@ bitflags = "1.2"
lazy_static = "1.4"
libc = "0.2"
parking_lot = "0.11"
ndarray = ">=0.13,<0.15"
ndarray = "0.15"
num-integer = "0.1"
num-traits = "0.2"
mpi-sys = { version = "0.1", optional = true }
errno = { version = "0.2", optional = true }
hdf5-sys = { path = "hdf5-sys", version = "0.7.1" } # !V
hdf5-types = { path = "hdf5-types", version = "0.7.1" } # !V
hdf5-derive = { path = "hdf5-derive", version = "0.7.1" } # !V
blosc-sys = { version = "0.1", package = "blosc-src", optional = true }
lzf-sys = { version = "0.1", optional = true }
cfg-if = "1.0"

[dev-dependencies]
paste = "1.0"
pretty_assertions = "0.6"
pretty_assertions = "0.7"
rand = { version = "0.8", features = ["small_rng"] }
regex = "1.3"
scopeguard = "1.0"
tempfile = "3.2"

[package.metadata.docs.rs]
features = ["hdf5-sys/static", "hdf5-sys/zlib"]
features = ["hdf5-sys/static", "hdf5-sys/zlib", "blosc", "lzf"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ fn main() -> hdf5::Result<()> {
{
// write
let file = hdf5::File::create("pixels.h5")?;
let colors = file.new_dataset::<Color>().create("colors", 2)?;
let colors = file.new_dataset::<Color>().shape(2).create("colors")?;
colors.write(&[RED, BLUE])?;
let group = file.create_group("dir")?;
let pixels = group.new_dataset::<Pixel>().create("pixels", (2, 2))?;
let pixels = group.new_dataset::<Pixel>().shape((2, 2)).create("pixels")?;
pixels.write(&arr2(&[
[Pixel { xy: (1, 2), color: RED }, Pixel { xy: (3, 4), color: BLUE }],
[Pixel { xy: (5, 6), color: GREEN }, Pixel { xy: (7, 8), color: RED }],
Expand Down
4 changes: 2 additions & 2 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ fn main() -> hdf5::Result<()> {
{
// write
let file = hdf5::File::create("pixels.h5")?;
let colors = file.new_dataset::<Color>().create("colors", 2)?;
let colors = file.new_dataset::<Color>().shape(2).create("colors")?;
colors.write(&[RED, BLUE])?;
let group = file.create_group("dir")?;
let pixels = group.new_dataset::<Pixel>().create("pixels", (2, 2))?;
let pixels = group.new_dataset::<Pixel>().shape((2, 2)).create("pixels")?;
pixels.write(&arr2(&[
[Pixel { xy: (1, 2), color: RED }, Pixel { xy: (3, 4), color: BLUE }],
[Pixel { xy: (5, 6), color: GREEN }, Pixel { xy: (7, 8), color: RED }],
Expand Down
2 changes: 1 addition & 1 deletion hdf5-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static = ["hdf5-src"]
deprecated = ["hdf5-src/deprecated"]

[build-dependencies]
libloading = "0.6"
libloading = "0.7"
regex = { version = "1.3", features = ["std"] }

[target.'cfg(all(unix, not(target_os = "macos")))'.build-dependencies]
Expand Down
42 changes: 20 additions & 22 deletions hdf5-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Display for RuntimeError {

#[allow(non_snake_case, non_camel_case_types)]
fn get_runtime_version_single<P: AsRef<Path>>(path: P) -> Result<Version, Box<dyn Error>> {
let lib = libloading::Library::new(path.as_ref())?;
let lib = unsafe { libloading::Library::new(path.as_ref()) }?;

type H5open_t = unsafe extern "C" fn() -> c_int;
let H5open = unsafe { lib.get::<H5open_t>(b"H5open")? };
Expand Down Expand Up @@ -124,28 +124,26 @@ fn validate_runtime_version(config: &Config) {
}
for link_path in &link_paths {
if let Ok(paths) = fs::read_dir(link_path) {
for path in paths {
if let Ok(path) = path {
let path = path.path();
if let Some(filename) = path.file_name() {
let filename = filename.to_str().unwrap_or("");
if path.is_file() && libfiles.contains(&filename) {
println!("Attempting to load: {:?}", path);
match get_runtime_version_single(&path) {
Ok(version) => {
println!(" => runtime version = {:?}", version);
if version == config.header.version {
println!("HDF5 library runtime version matches headers.");
return;
}
panic!(
"Invalid HDF5 runtime version (expected: {:?}).",
config.header.version
);
}
Err(err) => {
println!(" => {}", err);
for path in paths.flatten() {
let path = path.path();
if let Some(filename) = path.file_name() {
let filename = filename.to_str().unwrap_or("");
if path.is_file() && libfiles.contains(&filename) {
println!("Attempting to load: {:?}", path);
match get_runtime_version_single(&path) {
Ok(version) => {
println!(" => runtime version = {:?}", version);
if version == config.header.version {
println!("HDF5 library runtime version matches headers.");
return;
}
panic!(
"Invalid HDF5 runtime version (expected: {:?}).",
config.header.version
);
}
Err(err) => {
println!(" => {}", err);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions hdf5-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::missing_safety_doc))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::cognitive_complexity))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::upper_case_acronyms))]

macro_rules! extern_static {
($dest:ident, $src:ident) => {
Expand Down
6 changes: 5 additions & 1 deletion hdf5-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ description = "Native Rust equivalents of HDF5 types."
repository = "https://github.com/aldanor/hdf5-rust"
homepage = "https://github.com/aldanor/hdf5-rust"
edition = "2018"
build = "build.rs"

[features]
const_generics = []
h5-alloc = []

[dependencies]
ascii = "1.0"
libc = "0.2"
hdf5-sys = { version = "0.7.1", path = "../hdf5-sys" } # !V
cfg-if = "1.0.0"

[dev-dependencies]
quickcheck = { version = "1.0", default-features = false }
unindent = "0.1"
6 changes: 6 additions & 0 deletions hdf5-types/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
println!("cargo:rerun-if-changed=build.rs");
if std::env::var_os("DEP_HDF5_MSVC_DLL_INDIRECTION").is_some() {
println!("cargo:rustc-cfg=windows_dll");
}
}
88 changes: 17 additions & 71 deletions hdf5-types/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,76 +14,22 @@ pub unsafe trait Array: 'static {
fn capacity() -> usize;
}

#[cfg(not(feature = "const_generics"))]
mod impl_array {
use super::*;

macro_rules! impl_array {
() => ();

($n:expr, $($ns:expr,)*) => (
unsafe impl<T: 'static> Array for [T; $n] {
type Item = T;

#[inline(always)]
fn as_ptr(&self) -> *const T {
self as *const _ as *const _
}

#[inline(always)]
fn as_mut_ptr(&mut self) -> *mut T {
self as *mut _ as *mut _
}

#[inline(always)]
fn capacity() -> usize {
$n
}
}
unsafe impl<T: 'static, const N: usize> Array for [T; N] {
type Item = T;

impl_array!($($ns,)*);
);
#[inline(always)]
fn as_ptr(&self) -> *const T {
self as *const _
}

impl_array!(
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31,
);
impl_array!(
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, 62, 63,
);
impl_array!(
64, 70, 72, 80, 90, 96, 100, 110, 120, 128, 130, 140, 150, 160, 170, 180, 190, 192, 200,
210, 220, 224, 230, 240, 250,
);
impl_array!(
256, 300, 365, 366, 384, 400, 500, 512, 600, 700, 768, 800, 900, 1000, 1024, 2048, 4096,
8192, 16384, 32768,
);
}

#[cfg(feature = "const_generics")]
mod impl_array {
use super::*;

unsafe impl<T: 'static, const N: usize> Array for [T; N] {
type Item = T;

#[inline(always)]
fn as_ptr(&self) -> *const T {
self as *const _
}

#[inline(always)]
fn as_mut_ptr(&mut self) -> *mut T {
self as *mut _ as *mut _
}
#[inline(always)]
fn as_mut_ptr(&mut self) -> *mut T {
self as *mut _ as *mut _
}

#[inline(always)]
fn capacity() -> usize {
N
}
#[inline(always)]
fn capacity() -> usize {
N
}
}

Expand All @@ -97,7 +43,7 @@ pub struct VarLenArray<T: Copy> {
impl<T: Copy> VarLenArray<T> {
pub unsafe fn from_parts(p: *const T, len: usize) -> VarLenArray<T> {
let (len, ptr) = if !p.is_null() && len != 0 {
let dst = libc::malloc(len * mem::size_of::<T>());
let dst = crate::malloc(len * mem::size_of::<T>());
ptr::copy_nonoverlapping(p, dst as *mut _, len);
(len, dst)
} else {
Expand Down Expand Up @@ -136,7 +82,7 @@ impl<T: Copy> Drop for VarLenArray<T> {
fn drop(&mut self) {
if !self.ptr.is_null() {
unsafe {
libc::free(self.ptr as *mut _);
crate::free(self.ptr as *mut _);
}
self.ptr = ptr::null();
if self.len != 0 {
Expand Down Expand Up @@ -173,10 +119,10 @@ impl<'a, T: Copy> From<&'a [T]> for VarLenArray<T> {
}
}

impl<T: Copy> Into<Vec<T>> for VarLenArray<T> {
impl<T: Copy> From<VarLenArray<T>> for Vec<T> {
#[inline]
fn into(self) -> Vec<T> {
self.iter().cloned().collect()
fn from(v: VarLenArray<T>) -> Self {
v.iter().cloned().collect()
}
}

Expand Down
Loading