diff --git a/examples/sparse_http_reqwest.rs b/examples/sparse_http_reqwest.rs
index 509f3112..94151f07 100644
--- a/examples/sparse_http_reqwest.rs
+++ b/examples/sparse_http_reqwest.rs
@@ -1,4 +1,4 @@
-use crates_index::{SparseIndex};
+use crates_index::SparseIndex;
///
/// **important**:
@@ -18,18 +18,18 @@ fn main() {
print_crate(&mut index);
}
-fn print_crate(index: &mut SparseIndex){
+fn print_crate(index: &mut SparseIndex) {
match index.crate_from_cache(CRATE_TO_FETCH) {
Ok(krate) => {
println!("{:?}", krate.highest_normal_version().unwrap().version());
}
Err(_err) => {
- println!("could not find crate {}",CRATE_TO_FETCH)
+ println!("could not find crate {}", CRATE_TO_FETCH)
}
}
}
-fn update(index: &mut SparseIndex){
+fn update(index: &mut SparseIndex) {
let req = index.make_cache_request(CRATE_TO_FETCH).unwrap().body(()).unwrap();
let (parts, _) = req.into_parts();
@@ -41,9 +41,7 @@ fn update(index: &mut SparseIndex){
let res = client.execute(req).unwrap();
- let mut builder = http::Response::builder()
- .status(res.status())
- .version(res.version());
+ let mut builder = http::Response::builder().status(res.status()).version(res.version());
builder
.headers_mut()
@@ -54,4 +52,4 @@ fn update(index: &mut SparseIndex){
let res = builder.body(body.to_vec()).unwrap();
index.parse_cache_response(CRATE_TO_FETCH, res, true).unwrap();
-}
\ No newline at end of file
+}
diff --git a/examples/sparse_http_ureq.rs b/examples/sparse_http_ureq.rs
index 42a59e86..3f939b9c 100644
--- a/examples/sparse_http_ureq.rs
+++ b/examples/sparse_http_ureq.rs
@@ -1,5 +1,5 @@
+use crates_index::SparseIndex;
use std::io;
-use crates_index::{SparseIndex};
///
/// **important**:
@@ -19,27 +19,28 @@ fn main() {
print_crate(&mut index);
}
-fn print_crate(index: &mut SparseIndex){
+fn print_crate(index: &mut SparseIndex) {
match index.crate_from_cache(CRATE_TO_FETCH) {
Ok(krate) => {
println!("{:?}", krate.highest_normal_version().unwrap().version());
}
Err(_err) => {
- println!("could not find crate {}",CRATE_TO_FETCH)
+ println!("could not find crate {}", CRATE_TO_FETCH)
}
}
}
-fn update(index: &mut SparseIndex){
+fn update(index: &mut SparseIndex) {
let request: ureq::Request = index.make_cache_request(CRATE_TO_FETCH).unwrap().into();
let response: http::Response = request
.call()
- .map_err(|_e| io::Error::new(io::ErrorKind::InvalidInput, "connection error")).unwrap()
+ .map_err(|_e| io::Error::new(io::ErrorKind::InvalidInput, "connection error"))
+ .unwrap()
.into();
let (parts, body) = response.into_parts();
let response = http::Response::from_parts(parts, body.into_bytes());
index.parse_cache_response(CRATE_TO_FETCH, response, true).unwrap();
-}
\ No newline at end of file
+}
diff --git a/examples/update_and_get_latest.rs b/examples/update_and_get_latest.rs
index 14c1605d..c625a728 100644
--- a/examples/update_and_get_latest.rs
+++ b/examples/update_and_get_latest.rs
@@ -3,12 +3,16 @@ fn main() -> Result<(), Box> {
let mut index = crates_index::Index::new_cargo_default()?;
println!("Updating index…");
index.update()?;
-
+
let limit = 10;
println!("The most recent {limit} changes:\n");
for change in index.changes()?.take(limit) {
let change = change?;
- println!("{name} changed in {commit}", name = change.crate_name(), commit = change.commit_hex());
+ println!(
+ "{name} changed in {commit}",
+ name = change.crate_name(),
+ commit = change.commit_hex()
+ );
}
Ok(())
-}
\ No newline at end of file
+}
diff --git a/rustfmt.toml b/rustfmt.toml
index c7ad93ba..0a453277 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -1 +1,2 @@
-disable_all_formatting = true
+max_width = 120
+disable_all_formatting = false
diff --git a/src/bare_index/changes.rs b/src/bare_index/changes.rs
index 1d609b0c..a460458a 100644
--- a/src/bare_index/changes.rs
+++ b/src/bare_index/changes.rs
@@ -68,7 +68,15 @@ impl<'repo> Iterator for ChangesIter<'repo> {
};
let parent_tree = parent.tree().ok()?;
let time = SystemTime::UNIX_EPOCH + Duration::from_secs(self.current.time().ok()?.seconds.max(0) as _);
- Self::tree_additions(&self.repo, &mut self.out, time, &self.current.id(), &self.current_tree, &parent_tree).ok()?;
+ Self::tree_additions(
+ &self.repo,
+ &mut self.out,
+ time,
+ &self.current.id(),
+ &self.current_tree,
+ &parent_tree,
+ )
+ .ok()?;
self.current_tree = parent_tree;
self.current = parent;
}
@@ -78,7 +86,11 @@ impl<'repo> Iterator for ChangesIter<'repo> {
impl<'repo> ChangesIter<'repo> {
pub(crate) fn new(index: &'repo Index) -> Result {
- let current = index.repo.find_object(index.head_commit)?.peel_to_kind(gix::object::Kind::Commit)?.into_commit();
+ let current = index
+ .repo
+ .find_object(index.head_commit)?
+ .peel_to_kind(gix::object::Kind::Commit)?
+ .into_commit();
let current_tree = current.tree()?;
Ok(Self {
@@ -90,7 +102,13 @@ impl<'repo> ChangesIter<'repo> {
}
fn get_parent(&self) -> Result