Skip to content

Commit 64bb63f

Browse files
committed
Dataspace.clone() -> Dataspace.copy()
1 parent c5cfba7 commit 64bb63f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

hdf5-rs/src/hl/space.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ impl Deref for Dataspace {
5353
}
5454

5555
impl Dataspace {
56+
/// Copies the dataspace.
57+
pub fn copy(&self) -> Result<Self> {
58+
Self::from_id(h5call!(H5Scopy(self.id()))?)
59+
}
60+
5661
/// Select a slice (known as a 'hyperslab' in HDF5 terminology) of the Dataspace.
5762
/// Returns the shape of array that is capable of holding the resulting slice.
5863
/// Useful when you want to read a subset of a dataset.
@@ -160,13 +165,6 @@ impl Dimension for Dataspace {
160165
}
161166
}
162167

163-
impl Clone for Dataspace {
164-
fn clone(&self) -> Self {
165-
let id = h5call!(H5Scopy(self.id())).unwrap_or(H5I_INVALID_HID);
166-
Self::from_id(id).ok().unwrap_or_else(Self::invalid)
167-
}
168-
}
169-
170168
#[cfg(test)]
171169
pub mod tests {
172170
use crate::internal_prelude::*;
@@ -214,7 +212,7 @@ pub mod tests {
214212

215213
assert_err!(Dataspace::from_id(H5I_INVALID_HID), "Invalid dataspace id");
216214

217-
let dc = d.clone();
215+
let dc = d.copy().unwrap();
218216
assert!(dc.is_valid());
219217
assert_ne!(dc.id(), d.id());
220218
assert_eq!((d.ndim(), d.dims(), d.size()), (dc.ndim(), dc.dims(), dc.size()));

0 commit comments

Comments
 (0)