Skip to content

Commit f4a6fc0

Browse files
committed
The .copy() method now returns Self (unwrapped)
1 parent 734ec53 commit f4a6fc0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

hdf5-rs/src/hl/plist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ impl FromStr for PropertyListClass {
151151

152152
impl PropertyList {
153153
/// Copies the property list.
154-
pub fn copy(&self) -> Result<Self> {
155-
Self::from_id(h5call!(H5Pcopy(self.id()))?)
154+
pub fn copy(&self) -> Self {
155+
Self::from_id(h5lock!(H5Pcopy(self.id()))).unwrap_or_else(|_| Self::invalid())
156156
}
157157

158158
/// Queries whether a property name exists in the property list.
@@ -243,7 +243,7 @@ pub mod tests {
243243
pub fn test_clone() {
244244
let (fapl, _) = make_plists();
245245
assert!(fapl.is_valid());
246-
let fapl_c = fapl.copy().unwrap();
246+
let fapl_c = fapl.copy();
247247
assert!(fapl.is_valid());
248248
assert!(fapl_c.is_valid());
249249
assert_eq!(fapl.refcount(), 1);

hdf5-rs/src/hl/plist/file_create.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ impl FileCreate {
395395
Self::from_id(h5try!(H5Pcreate(*H5P_FILE_CREATE)))
396396
}
397397

398-
pub fn copy(&self) -> Result<Self> {
399-
Ok(unsafe { self.deref().copy()?.cast() })
398+
pub fn copy(&self) -> Self {
399+
unsafe { self.deref().copy().cast() }
400400
}
401401

402402
pub fn build() -> FileCreateBuilder {

hdf5-rs/src/hl/space.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl Deref for Dataspace {
5555

5656
impl Dataspace {
5757
/// Copies the dataspace.
58-
pub fn copy(&self) -> Result<Self> {
59-
Self::from_id(h5call!(H5Scopy(self.id()))?)
58+
pub fn copy(&self) -> Self {
59+
Self::from_id(h5lock!(H5Scopy(self.id()))).unwrap_or_else(|_| Self::invalid())
6060
}
6161

6262
/// Select a slice (known as a 'hyperslab' in HDF5 terminology) of the Dataspace.
@@ -213,7 +213,7 @@ pub mod tests {
213213

214214
assert_err!(Dataspace::from_id(H5I_INVALID_HID), "Invalid dataspace id");
215215

216-
let dc = d.copy().unwrap();
216+
let dc = d.copy();
217217
assert!(dc.is_valid());
218218
assert_ne!(dc.id(), d.id());
219219
assert_eq!((d.ndim(), d.dims(), d.size()), (dc.ndim(), dc.dims(), dc.size()));

0 commit comments

Comments
 (0)