Skip to content

Commit 2db579f

Browse files
authored
cargo clippy --fix && cargo fmt --all (#9)
1 parent bee215a commit 2db579f

File tree

6 files changed

+10
-11
lines changed

6 files changed

+10
-11
lines changed

onnxruntime-sys/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,15 @@ fn extract_archive(filename: &Path, output: &Path) {
270270
}
271271

272272
fn extract_tgz(filename: &Path, output: &Path) {
273-
let file = fs::File::open(&filename).unwrap();
273+
let file = fs::File::open(filename).unwrap();
274274
let buf = io::BufReader::new(file);
275275
let tar = flate2::read::GzDecoder::new(buf);
276276
let mut archive = tar::Archive::new(tar);
277277
archive.unpack(output).unwrap();
278278
}
279279

280280
fn extract_zip(filename: &Path, outpath: &Path) {
281-
let file = fs::File::open(&filename).unwrap();
281+
let file = fs::File::open(filename).unwrap();
282282
let buf = io::BufReader::new(file);
283283
let mut archive = zip::ZipArchive::new(buf).unwrap();
284284
for i in 0..archive.len() {
@@ -294,7 +294,7 @@ fn extract_zip(filename: &Path, outpath: &Path) {
294294
);
295295
if let Some(p) = outpath.parent() {
296296
if !p.exists() {
297-
fs::create_dir_all(&p).unwrap();
297+
fs::create_dir_all(p).unwrap();
298298
}
299299
}
300300
let mut outfile = fs::File::create(&outpath).unwrap();

onnxruntime-sys/examples/c_api_sample.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ fn main() {
289289
let input_node_names_ptr_ptr: *const *const i8 = input_node_names_ptr.as_ptr();
290290

291291
let output_node_names_cstring: Vec<std::ffi::CString> = output_node_names
292-
.into_iter()
292+
.iter()
293293
.map(|n| std::ffi::CString::new(n.clone()).unwrap())
294294
.collect();
295295
let output_node_names_ptr: Vec<*const i8> = output_node_names_cstring

onnxruntime/examples/print_structure.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use std::error::Error;
55
fn main() -> Result<(), Box<dyn Error>> {
66
// provide path to .onnx model on disk
77
let path = std::env::args()
8-
.skip(1)
9-
.next()
8+
.nth(1)
109
.expect("Must provide an .onnx file as the first arg");
1110

1211
let environment = environment::Environment::builder()

onnxruntime/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ impl From<*const sys::OrtStatus> for OrtStatusWrapper {
197197

198198
pub(crate) fn assert_null_pointer<T>(ptr: *const T, name: &str) -> Result<()> {
199199
ptr.is_null()
200-
.then(|| ())
200+
.then_some(())
201201
.ok_or_else(|| OrtError::PointerShouldBeNull(name.to_owned()))
202202
}
203203

204204
pub(crate) fn assert_not_null_pointer<T>(ptr: *const T, name: &str) -> Result<()> {
205205
(!ptr.is_null())
206-
.then(|| ())
206+
.then_some(())
207207
.ok_or_else(|| OrtError::PointerShouldBeNull(name.to_owned()))
208208
}
209209

onnxruntime/src/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ mod dangerous {
758758
let status = unsafe { f(session_ptr, &mut num_nodes) };
759759
status_to_result(status).map_err(OrtError::InOutCount)?;
760760
assert_null_pointer(status, "SessionStatus")?;
761-
(num_nodes != 0).then(|| ()).ok_or_else(|| {
761+
(num_nodes != 0).then_some(()).ok_or_else(|| {
762762
OrtError::InOutCount(OrtApiError::Msg("No nodes in model".to_owned()))
763763
})?;
764764
Ok(num_nodes)
@@ -862,7 +862,7 @@ mod dangerous {
862862
unsafe { g_ort().GetTensorElementType.unwrap()(tensor_info_ptr, &mut type_sys) };
863863
status_to_result(status).map_err(OrtError::TensorElementType)?;
864864
(type_sys != sys::ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED)
865-
.then(|| ())
865+
.then_some(())
866866
.ok_or(OrtError::UndefinedTensorElementType)?;
867867
// This transmute should be safe since its value is read from GetTensorElementType which we must trust.
868868
let io_type: TensorElementDataType = unsafe { std::mem::transmute(type_sys) };

onnxruntime/src/tensor/ort_owned_tensor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ where
9797
let status = unsafe { g_ort().IsTensor.unwrap()(self.tensor_ptr, &mut is_tensor) };
9898
status_to_result(status).map_err(OrtError::IsTensor)?;
9999
(is_tensor == 1)
100-
.then(|| ())
100+
.then_some(())
101101
.ok_or(OrtError::IsTensorCheck)?;
102102

103103
// Get pointer to output tensor float values

0 commit comments

Comments
 (0)