From 83b03d2996a9a6e573721164ad9a308aca4d2f88 Mon Sep 17 00:00:00 2001 From: Luca BRUNO Date: Wed, 1 Dec 2021 15:18:47 +0000 Subject: [PATCH] lib: run rustfmt --- rust-bindings/rust/src/object_details.rs | 14 +++++++------ rust-bindings/rust/src/repo.rs | 11 ++++++---- rust-bindings/rust/tests/functions/mod.rs | 25 ++++++++++++++++------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/rust-bindings/rust/src/object_details.rs b/rust-bindings/rust/src/object_details.rs index f6adcc81..3dfb8432 100644 --- a/rust-bindings/rust/src/object_details.rs +++ b/rust-bindings/rust/src/object_details.rs @@ -1,6 +1,6 @@ use std::fmt::Display; -use std::fmt::Formatter; use std::fmt::Error; +use std::fmt::Formatter; /// Details of an object in an OSTree repo. It contains information about if /// the object is "loose", and contains a list of pack file checksums in which @@ -32,11 +32,13 @@ impl ObjectDetails { } } -impl Display for ObjectDetails{ +impl Display for ObjectDetails { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { - write!(f, "Object is {} and appears in {} checksums", - if self.loose {"loose"} else {"not loose"}, - self.object_appearances.len() ) + write!( + f, + "Object is {} and appears in {} checksums", + if self.loose { "loose" } else { "not loose" }, + self.object_appearances.len() + ) } } - diff --git a/rust-bindings/rust/src/repo.rs b/rust-bindings/rust/src/repo.rs index 6a44103b..5329b893 100644 --- a/rust-bindings/rust/src/repo.rs +++ b/rust-bindings/rust/src/repo.rs @@ -1,6 +1,6 @@ #[cfg(any(feature = "v2016_4", feature = "dox"))] use crate::RepoListRefsExtFlags; -use crate::{Checksum, ObjectName, ObjectDetails, ObjectType, Repo, RepoTransactionStats}; +use crate::{Checksum, ObjectDetails, ObjectName, ObjectType, Repo, RepoTransactionStats}; use ffi::OstreeRepoListObjectsFlags; use glib::ffi as glib_sys; use glib::{self, translate::*, Error, IsA}; @@ -30,7 +30,8 @@ unsafe extern "C" fn read_variant_object_map( ) { let key: glib::Variant = from_glib_none(key as *const glib_sys::GVariant); let value: glib::Variant = from_glib_none(value as *const glib_sys::GVariant); - let set: &mut HashMap = &mut *(hash_set as *mut HashMap); + let set: &mut HashMap = + &mut *(hash_set as *mut HashMap); if let Some(details) = ObjectDetails::new_from_variant(value) { set.insert(ObjectName::new_from_variant(key), details); } @@ -47,7 +48,9 @@ unsafe fn from_glib_container_variant_set(ptr: *mut glib_sys::GHashTable) -> Has set } -unsafe fn from_glib_container_variant_map(ptr: *mut glib_sys::GHashTable) -> HashMap { +unsafe fn from_glib_container_variant_map( + ptr: *mut glib_sys::GHashTable, +) -> HashMap { let mut set = HashMap::new(); glib_sys::g_hash_table_foreach( ptr, @@ -186,7 +189,7 @@ impl Repo { flags, &mut hashtable, cancellable.map(AsRef::as_ref).to_glib_none().0, - &mut error + &mut error, ); if error.is_null() { diff --git a/rust-bindings/rust/tests/functions/mod.rs b/rust-bindings/rust/tests/functions/mod.rs index 933bc897..9fa3a918 100644 --- a/rust-bindings/rust/tests/functions/mod.rs +++ b/rust-bindings/rust/tests/functions/mod.rs @@ -11,17 +11,28 @@ fn list_repo_objects() { let mut file_cnt = 0; let mut commit_cnt = 0; - let objects = repo.repo.list_objects( ffi::OSTREE_REPO_LIST_OBJECTS_ALL, NONE_CANCELLABLE).expect("List Objects"); + let objects = repo + .repo + .list_objects(ffi::OSTREE_REPO_LIST_OBJECTS_ALL, NONE_CANCELLABLE) + .expect("List Objects"); for (object, _items) in objects { - match object.object_type() { - ObjectType::DirTree => { dirtree_cnt += 1; }, - ObjectType::DirMeta => { dirmeta_cnt += 1; }, - ObjectType::File => { file_cnt += 1; }, + match object.object_type() { + ObjectType::DirTree => { + dirtree_cnt += 1; + } + ObjectType::DirMeta => { + dirmeta_cnt += 1; + } + ObjectType::File => { + file_cnt += 1; + } ObjectType::Commit => { assert_eq!(commit_checksum.to_string(), object.checksum()); commit_cnt += 1; - }, - x => { panic!("unexpected object type {}", x ); } + } + x => { + panic!("unexpected object type {}", x); + } } } assert_eq!(dirtree_cnt, 2);