Skip to content

Commit 7647d1e

Browse files
committed
Allow deprecated set_comment (with warning)
1 parent e137345 commit 7647d1e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/hl/location.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ use std::fmt::{self, Debug};
22
use std::ops::Deref;
33
use std::ptr;
44

5+
#[allow(deprecated)]
6+
use hdf5_sys::h5o::H5Oset_comment;
57
use hdf5_sys::{
68
h5f::H5Fget_name,
79
h5i::{H5Iget_file_id, H5Iget_name},
8-
h5o::{H5Oget_comment, H5Oset_comment},
10+
h5o::H5Oget_comment,
911
};
1012

1113
use crate::internal_prelude::*;
@@ -74,15 +76,19 @@ impl Location {
7476
}
7577

7678
/// Set or the commment attached to the named object.
79+
#[deprecated(note = "Attributes are preferred to comments")]
7780
pub fn set_comment(&self, comment: &str) -> Result<()> {
7881
// TODO: &mut self?
7982
let comment = to_cstring(comment)?;
83+
#[allow(deprecated)]
8084
h5call!(H5Oset_comment(self.id(), comment.as_ptr())).and(Ok(()))
8185
}
8286

8387
/// Clear the commment attached to the named object.
88+
#[deprecated(note = "Attributes are preferred to comments")]
8489
pub fn clear_comment(&self) -> Result<()> {
8590
// TODO: &mut self?
91+
#[allow(deprecated)]
8692
h5call!(H5Oset_comment(self.id(), ptr::null_mut())).and(Ok(()))
8793
}
8894
}
@@ -114,6 +120,7 @@ pub mod tests {
114120

115121
#[test]
116122
pub fn test_comment() {
123+
#[allow(deprecated)]
117124
with_tmp_file(|file| {
118125
assert!(file.comment().is_none());
119126
assert!(file.set_comment("foo").is_ok());

0 commit comments

Comments
 (0)