Skip to content

Commit 845f040

Browse files
abrownstevelr
andauthored
fix: clippy warnings (#80)
Signed-off-by: stevelr <[email protected]> Co-authored-by: stevelr <[email protected]>
1 parent e5bf544 commit 845f040

File tree

6 files changed

+27
-25
lines changed

6 files changed

+27
-25
lines changed

crates/openvino-finder/src/lib.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
//! If you do run into problems, the following chart summarizes some of the known installation
2626
//! locations of the OpenVINO files as of version `2022.3.0`:
2727
//!
28-
//! | Installation Method | Path | Available on | Notes |
29-
//! | ------------------- | -------------------------------------------------- | --------------------- | -------------------------------- |
30-
//! | Archive (`.tar.gz`) | `<extracted folder>/runtime/lib/<arch>` | Linux | `<arch>`: `intel64,armv7l,arm64` |
31-
//! | Archive (`.tar.gz`) | `<extracted folder>/runtime/lib/<arch>/Release` | MacOS | `<arch>`: `intel64,armv7l,arm64` |
32-
//! | Archive (`.zip`) | `<unzipped folder>/runtime/bin/<arch>/Release` | Windows | `<arch>`: `intel64,armv7l,arm64` |
33-
//! | PyPI | `<pip install folder>/site-packages/openvino/libs` | Linux, MacOS, Windows | Find install folder with `pip show openvino` |
34-
//! | DEB | `/usr/lib/x86_64-linux-gnu/openvino-<version>/` | Linux (APT-based) | This path is for plugins; the libraries are one directory above |
35-
//! | RPM | `/usr/lib64/` | Linux (YUM-based) | |
28+
//! | Installation Method | Path | Available on | Notes |
29+
//! | ------------------- | -------------------------------------------------- | ----------------------- | -------------------------------- |
30+
//! | Archive (`.tar.gz`) | `<extracted folder>/runtime/lib/<arch>` | Linux | `<arch>`: `intel64,armv7l,arm64` |
31+
//! | Archive (`.tar.gz`) | `<extracted folder>/runtime/lib/<arch>/Release` | `MacOS` | `<arch>`: `intel64,armv7l,arm64` |
32+
//! | Archive (`.zip`) | `<unzipped folder>/runtime/bin/<arch>/Release` | Windows | `<arch>`: `intel64,armv7l,arm64` |
33+
//! | `PyPI` | `<pip install folder>/site-packages/openvino/libs` | Linux, `MacOS`, Windows | Find install folder with `pip show openvino` |
34+
//! | DEB | `/usr/lib/x86_64-linux-gnu/openvino-<version>/` | Linux (APT-based) | This path is for plugins; the libraries are one directory above |
35+
//! | RPM | `/usr/lib64/` | Linux (YUM-based) | |
3636
3737
#![deny(missing_docs)]
3838
#![deny(clippy::all)]
@@ -83,6 +83,10 @@ macro_rules! check_and_return {
8383
/// The locations above may change over time. As OpenVINO has released new versions, the documented
8484
/// locations of the shared libraries has changed. New versions of this function will reflect this,
8585
/// removing older, unused locations over time.
86+
///
87+
/// # Panics
88+
///
89+
/// Panics if it cannot list the contents of a search directory.
8690
pub fn find(library_name: &str) -> Option<PathBuf> {
8791
let file = format!(
8892
"{}{}{}",
@@ -295,7 +299,7 @@ fn build_latest_version(dir: &Path, prefix: &str, mut versions: Vec<String>) ->
295299
let latest_version = versions
296300
.first()
297301
.expect("already checked that a version exists");
298-
let filename = format!("{}{}", prefix, latest_version);
302+
let filename = format!("{prefix}{latest_version}");
299303
Some(dir.join(filename))
300304
}
301305

crates/openvino/src/blob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Blob {
5757
/// dimensions array with a size different than the one auto-generated in the bindings; see
5858
/// `struct dimensions` in `openvino-sys/src/generated/types.rs`.
5959
pub fn tensor_desc(&self) -> Result<TensorDesc> {
60-
let blob = self.instance as *const ie_blob_t;
60+
let blob = self.instance.cast_const();
6161

6262
let mut layout = MaybeUninit::uninit();
6363
try_unsafe!(ie_blob_get_layout(blob, layout.as_mut_ptr()))?;

crates/openvino/src/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Core {
3737
.ok_or(LoadingError::CannotStringifyPath)?
3838
.to_string())
3939
} else {
40-
cstr!("".to_string())
40+
cstr!(String::new())
4141
};
4242

4343
let mut instance = std::ptr::null_mut();

crates/openvino/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ pub use request::InferRequest;
4646
pub use tensor_desc::TensorDesc;
4747

4848
/// Emit the version string of the OpenVINO C API backing this implementation.
49+
///
50+
/// # Panics
51+
///
52+
/// Panics if no OpenVINO library can be found.
4953
pub fn version() -> String {
5054
use std::ffi::CStr;
5155
openvino_sys::load().expect("to have an OpenVINO shared library available");

crates/xtask/src/bump.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::util::{get_crates, Crate};
2-
use anyhow::{anyhow, Context, Result};
2+
use anyhow::{bail, Context, Result};
33
use clap::Args;
44
use semver::{BuildMetadata, Prerelease};
55
use std::fs;
@@ -31,10 +31,7 @@ impl BumpCommand {
3131
.windows(2)
3232
.all(|w| w[0].version == w[1].version)
3333
{
34-
anyhow!(
35-
"Not all crate versions are the same: {:?}",
36-
publishable_crates
37-
);
34+
bail!("Not all crate versions are the same: {publishable_crates:?}");
3835
}
3936

4037
// Change the version. Unless specified with a custom version, the `pre` and `build`
@@ -70,7 +67,7 @@ impl BumpCommand {
7067
}
7168

7269
// Add a Git commit.
73-
let commit_message = format!("Release v{}", next_version_str);
70+
let commit_message = format!("Release v{next_version_str}");
7471
if self.git {
7572
println!("> add Git commit: {}", &commit_message);
7673
if !self.dry_run && self.git {

crates/xtask/src/publish.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::util::{exec, get_crates, path_to_crates, Crate};
2-
use anyhow::{anyhow, Result};
2+
use anyhow::{bail, Result};
33
use clap::Args;
44
use std::{process::Command, thread::sleep, time::Duration};
55

@@ -25,10 +25,7 @@ impl PublishCommand {
2525
.windows(2)
2626
.all(|w| w[0].version == w[1].version)
2727
{
28-
anyhow!(
29-
"Not all crate versions are the same: {:?}",
30-
publishable_crates
31-
);
28+
bail!("Not all crate versions are the same: {publishable_crates:?}");
3229
}
3330

3431
// Check that all of the publishable crates are in `PUBLICATION_ORDER`.
@@ -40,7 +37,7 @@ impl PublishCommand {
4037
// Publish each crate.
4138
let crates_dir = path_to_crates()?;
4239
for krate in PUBLICATION_ORDER {
43-
println!("> publish {}", krate);
40+
println!("> publish {krate}");
4441
if !self.dry_run {
4542
let krate_dir = crates_dir.clone().join(krate);
4643
let exec_result = exec(
@@ -53,7 +50,7 @@ impl PublishCommand {
5350
// We want to continue even if a crate does not publish: this allows us to re-run
5451
// the `publish` command if uploading one or more crates fails.
5552
if let Err(e) = exec_result {
56-
println!("Failed to publish crate {}, continuing:\n {}", krate, e);
53+
println!("Failed to publish crate {krate}, continuing:\n {e}");
5754
}
5855

5956
// Hopefully this gives crates.io enough time for subsequent publications to work.
@@ -64,7 +61,7 @@ impl PublishCommand {
6461
// Tag the repository.
6562
let tag = format!("v{}", publishable_crates[0].version);
6663
if self.git {
67-
println!("> push Git tag: {}", tag);
64+
println!("> push Git tag: {tag}");
6865
if !self.dry_run {
6966
exec(Command::new("git").arg("tag").arg(&tag))?;
7067
exec(Command::new("git").arg("push").arg("origin").arg(&tag))?;

0 commit comments

Comments
 (0)