Skip to content

Commit 0bc3a8f

Browse files
authored
lint: fix several new lint issues found (#60)
* lint: fix several new lint issues found These likely are due to a new version of clippy somewhere. * fix: use `product()`
1 parent 14c4e43 commit 0bc3a8f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

crates/openvino/src/blob.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ impl Blob {
5050
}
5151

5252
/// Return the tensor description of this [`Blob`].
53+
///
54+
/// # Panics
55+
///
56+
/// May panic in the improbable case where some future version of the OpenVINO library returns a
57+
/// dimensions array with a size different than the one auto-generated in the bindings; see
58+
/// `struct dimensions` in `openvino-sys/src/generated/types.rs`.
5359
pub fn tensor_desc(&self) -> Result<TensorDesc> {
5460
let blob = self.instance as *const ie_blob_t;
5561

@@ -58,11 +64,9 @@ impl Blob {
5864

5965
let mut dimensions = MaybeUninit::uninit();
6066
try_unsafe!(ie_blob_get_dims(blob, dimensions.as_mut_ptr()))?;
61-
// Safety: this assertion is trying to avoid the improbable case where some future version
62-
// of the OpenVINO library returns a dimensions array with size different than the one
63-
// auto-generated in the bindings; see `struct dimensions` in
64-
// `openvino-sys/src/generated/types.rs`. It is not clear to me whether this will return the
65-
// statically-expected size or the dynamic size -- this is not effective in the former case.
67+
// Safety: See `Panics` section in function documentation; itt is not clear to me whether
68+
// this will return the statically-expected size or the dynamic size -- this is not
69+
// effective in the former case.
6670
assert_eq!(unsafe { dimensions.assume_init() }.dims.len(), 8);
6771

6872
let mut precision = MaybeUninit::uninit();

crates/openvino/src/tensor_desc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ impl TensorDesc {
5151

5252
/// Get the number of elements described by this [`TensorDesc`].
5353
pub fn len(&self) -> usize {
54-
self.dims().iter().fold(1, |a, &b| a * b as usize)
54+
self.dims().iter().product()
5555
}
5656
}

0 commit comments

Comments
 (0)