| 1 | //! A crate providing foundational capabilities to other `git-*` crates with trade-offs between compile time, binary size or speed |
| 2 | //! selectable using cargo feature toggles. |
| 3 | //! |
| 4 | //! It's designed to allow the application level crate to configure feature toggles, affecting all other `git-*` crates using |
| 5 | //! this one. |
| 6 | //! |
| 7 | //! Thus all features provided here commonly have a 'cheap' base implementation, with the option to pull in |
| 8 | //! counterparts with higher performance. |
| 9 | //! ## Feature Flags |
| 10 | #![cfg_attr( |
| 11 | all(doc, feature = "document-features"), |
| 12 | doc = ::document_features::document_features!() |
| 13 | )] |
| 14 | #![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg))] |
| 15 | #![deny(rust_2018_idioms, missing_docs)] |
| 16 | |
| 17 | /// |
| 18 | pub mod cacherust-analyzer cargo gix-features 0.48.0 cache/; |
| 19 | /// |
| 20 | pub mod decoderust-analyzer cargo gix-features 0.48.0 decode/; |
| 21 | pub mod fsrust-analyzer cargo gix-features 0.48.0 fs/; |
| 22 | pub mod hashrust-analyzer cargo gix-features 0.48.0 hash/; |
| 23 | pub mod interruptrust-analyzer cargo gix-features 0.48.0 interrupt/; |
| 24 | #[cfg(feature = "io-pipe")] |
| 25 | pub mod iorust-analyzer cargo gix-features 0.48.0 io/; |
| 26 | pub mod parallelrust-analyzer cargo gix-features 0.48.0 parallel/; |
| 27 | #[cfg(feature = "progress")] |
| 28 | pub mod progressrust-analyzer cargo gix-features 0.48.0 progress/; |
| 29 | pub mod threadingrust-analyzer cargo gix-features 0.48.0 threading/; |
| 30 | pub use gix_tracerust-analyzer cargo gix-trace 0.1.19 crate/ as tracerust-analyzer cargo gix-trace 0.1.19 crate/; |
| 31 | |
| 32 | /// |
| 33 | #[cfg(feature = "zlib")] |
| 34 | pub mod zlibrust-analyzer cargo gix-features 0.48.0 zlib/; |
| 35 | |
| 36 | /// |
| 37 | pub mod iterrust-analyzer cargo gix-features 0.48.0 iter/ { |
| 38 | /// An iterator over chunks of input, producing `Vec<Item>` with a size of `size`, with the last chunk being the remainder and thus |
| 39 | /// potentially smaller than `size`. |
| 40 | pub struct Chunksrust-analyzer cargo gix-features 0.48.0 iter/Chunks#<I> { |
| 41 | /// The inner iterator to ask for items. |
| 42 | pub innerrust-analyzer cargo gix-features 0.48.0 iter/Chunks#inner.: I, |
| 43 | /// The size of chunks to produce |
| 44 | pub sizerust-analyzer cargo gix-features 0.48.0 iter/Chunks#size.: usize, |
| 45 | } |
| 46 | |
| 47 | impl<I, Item> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Chunksrust-analyzer cargo gix-features 0.48.0 iter/Chunks#<I> |
| 48 | where |
| 49 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Item>, |
| 50 | { |
| 51 | type Itemrust-analyzer cargo gix-features 0.48.0 iter/impl#[`Chunks<I>`][Iterator]Item# = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Item>; |
| 52 | |
| 53 | fn nextrust-analyzer cargo gix-features 0.48.0 iter/impl#[`Chunks<I>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo gix-features 0.48.0 iter/impl#[`Chunks<I>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 54 | let mut res = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(self.sizerust-analyzer cargo gix-features 0.48.0 iter/Chunks#size.); |
| 55 | let mut items_left = self.sizerust-analyzer cargo gix-features 0.48.0 iter/Chunks#size.; |
| 56 | for item in &mut self.innerrust-analyzer cargo gix-features 0.48.0 iter/Chunks#inner. { |
| 57 | res.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(item); |
| 58 | items_left rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1; |
| 59 | if items_left rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 60 | break; |
| 61 | } |
| 62 | } |
| 63 | (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().res.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(res) |
| 64 | } |
| 65 | } |
| 66 | } |