As otherwise, one cannot use `&dyn ` at all in this case as it's unsized.` Additionally, rename top-level `pub use gix_glob` to `glob` to be in-line with other public exports of this kind.
Unified · Split
| @@ -10,7 +10,8 @@ · 9 unmodified lines | ||
| 10 | 10 | #![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))] |
| 11 | 11 | #![deny(missing_docs, rust_2018_idioms, unsafe_code)] |
| 12 | 12 | use bstr::BString; |
| 13 | −pub use gix_glob; | |
| 13 | +/// A way to access the [`Case`](glob::pattern::Case) enum which used throughout this API. | |
| 14 | +pub use gix_glob as glob; | |
| 14 | 15 | |
| 15 | 16 | /// A cache for efficiently executing operations on directories and files which are encountered in sorted order. |
| 16 | 17 | /// That way, these operations can be re-used for subsequent invocations in the same directory. |
| @@ -108,22 +108,19 @@ impl Stack { · 107 unmodified lines | ||
| 108 | 108 | /// `objects` maybe used to lookup objects from an [id mapping][crate::stack::State::id_mappings_from_index()], with mappnigs |
| 109 | 109 | /// |
| 110 | 110 | /// Provide access to cached information for that `relative` path via the returned platform. |
| 111 | − pub fn at_path<Find>( | |
| 111 | + pub fn at_path( | |
| 112 | 112 | &mut self, |
| 113 | 113 | relative: impl AsRef<Path>, |
| 114 | 114 | is_dir: Option<bool>, |
| 115 | − objects: Find, | |
| 116 | − ) -> std::io::Result<Platform<'_>> | |
| 117 | − where | |
| 118 | − Find: gix_object::Find, | |
| 119 | − { | |
| 115 | + objects: &dyn gix_object::Find, | |
| 116 | + ) -> std::io::Result<Platform<'_>> { | |
| 120 | 117 | self.statistics.platforms += 1; |
| 121 | 118 | let mut delegate = StackDelegate { |
| 122 | 119 | state: &mut self.state, |
| 123 | 120 | buf: &mut self.buf, |
| 124 | 121 | is_dir: is_dir.unwrap_or(false), |
| 125 | 122 | id_mappings: &self.id_mappings, |
| 126 | − objects: &objects, | |
| 123 | + objects, | |
| 127 | 124 | case: self.case, |
| 128 | 125 | statistics: &mut self.statistics, |
| 129 | 126 | }; |
| @@ -142,15 +139,12 @@ impl Stack { · 12 unmodified lines | ||
| 142 | 139 | /// ### Panics |
| 143 | 140 | /// |
| 144 | 141 | /// on illformed UTF8 in `relative` |
| 145 | − pub fn at_entry<'r, Find>( | |
| 142 | + pub fn at_entry<'r>( | |
| 146 | 143 | &mut self, |
| 147 | 144 | relative: impl Into<&'r BStr>, |
| 148 | 145 | is_dir: Option<bool>, |
| 149 | − objects: Find, | |
| 150 | − ) -> std::io::Result<Platform<'_>> | |
| 151 | − where | |
| 152 | − Find: gix_object::Find, | |
| 153 | − { | |
| 146 | + objects: &dyn gix_object::Find, | |
| 147 | + ) -> std::io::Result<Platform<'_>> { | |
| 154 | 148 | let relative = relative.into(); |
| 155 | 149 | let relative_path = gix_path::from_bstr(relative); |
| 156 | 150 | |
| @@ -29,7 +29,7 @@ fn baseline() -> crate::Result { · 28 unmodified lines | ||
| 29 | 29 | let mut actual = cache.attribute_matches(); |
| 30 | 30 | let input = std::fs::read(base.join("baseline"))?; |
| 31 | 31 | for (rela_path, expected) in (baseline::Expectations { lines: input.lines() }) { |
| 32 | − let entry = cache.at_entry(rela_path, None, gix_object::find::Never)?; | |
| 32 | + let entry = cache.at_entry(rela_path, None, &gix_object::find::Never)?; | |
| 33 | 33 | let has_match = entry.matching_attributes(&mut actual); |
| 34 | 34 | |
| 35 | 35 | assert_eq!( |
| @@ -50,7 +50,7 @@ fn baseline() -> crate::Result { · 14 unmodified lines | ||
| 50 | 50 | let mut actual = cache.selected_attribute_matches(["info", "test"]); |
| 51 | 51 | let input = std::fs::read(base.join("baseline.selected"))?; |
| 52 | 52 | for (rela_path, expected) in (baseline::Expectations { lines: input.lines() }) { |
| 53 | − let entry = cache.at_entry(rela_path, None, gix_object::find::Never)?; | |
| 53 | + let entry = cache.at_entry(rela_path, None, &gix_object::find::Never)?; | |
| 54 | 54 | let has_match = entry.matching_attributes(&mut actual); |
| 55 | 55 | |
| 56 | 56 | assert_eq!( |
| @@ -15,7 +15,7 @@ fn root_is_assumed_to_exist_and_files_in_root_do_not_create_directory() -> crate · 14 unmodified lines | ||
| 15 | 15 | ); |
| 16 | 16 | assert_eq!(cache.statistics().delegate.num_mkdir_calls, 0); |
| 17 | 17 | |
| 18 | − let path = cache.at_path("hello", Some(false), gix_object::find::Never)?.path(); | |
| 18 | + let path = cache.at_path("hello", Some(false), &gix_object::find::Never)?.path(); | |
| 19 | 19 | assert!(!path.parent().unwrap().exists(), "prefix itself is never created"); |
| 20 | 20 | assert_eq!(cache.statistics().delegate.num_mkdir_calls, 0); |
| 21 | 21 | Ok(()) |
| @@ -33,7 +33,7 @@ fn directory_paths_are_created_in_full() { · 11 unmodified lines | ||
| 33 | 33 | ("link", None), |
| 34 | 34 | ] { |
| 35 | 35 | let path = cache |
| 36 | − .at_path(Path::new("dir").join(name), *is_dir, gix_object::find::Never) | |
| 36 | + .at_path(Path::new("dir").join(name), *is_dir, &gix_object::find::Never) | |
| 37 | 37 | .unwrap() |
| 38 | 38 | .path(); |
| 39 | 39 | assert!(path.parent().unwrap().is_dir(), "dir exists"); |
| @@ -47,7 +47,7 @@ fn existing_directories_are_fine() -> crate::Result { · 7 unmodified lines | ||
| 47 | 47 | let (mut cache, tmp) = new_cache(); |
| 48 | 48 | std::fs::create_dir(tmp.path().join("dir"))?; |
| 49 | 49 | |
| 50 | − let path = cache.at_path("dir/file", Some(false), gix_object::find::Never)?.path(); | |
| 50 | + let path = cache.at_path("dir/file", Some(false), &gix_object::find::Never)?.path(); | |
| 51 | 51 | assert!(path.parent().unwrap().is_dir(), "directory is still present"); |
| 52 | 52 | assert!(!path.exists(), "it won't create the file"); |
| 53 | 53 | assert_eq!(cache.statistics().delegate.num_mkdir_calls, 1); |
| @@ -72,7 +72,7 @@ fn symlinks_or_files_in_path_are_forbidden_or_unlinked_when_forced() -> crate::R · 18 unmodified lines | ||
| 72 | 72 | let relative_path = format!("{dirname}/file"); |
| 73 | 73 | assert_eq!( |
| 74 | 74 | cache |
| 75 | − .at_path(&relative_path, Some(false), gix_object::find::Never) | |
| 75 | + .at_path(&relative_path, Some(false), &gix_object::find::Never) | |
| 76 | 76 | .unwrap_err() |
| 77 | 77 | .kind(), |
| 78 | 78 | std::io::ErrorKind::AlreadyExists |
| @@ -93,7 +93,7 @@ fn symlinks_or_files_in_path_are_forbidden_or_unlinked_when_forced() -> crate::R · 14 unmodified lines | ||
| 93 | 93 | } |
| 94 | 94 | let relative_path = format!("{dirname}/file"); |
| 95 | 95 | let path = cache |
| 96 | − .at_path(&relative_path, Some(false), gix_object::find::Never)? | |
| 96 | + .at_path(&relative_path, Some(false), &gix_object::find::Never)? | |
| 97 | 97 | .path(); |
| 98 | 98 | assert!(path.parent().unwrap().is_dir(), "directory was forcefully created"); |
| 99 | 99 | assert!(!path.exists()); |
| @@ -65,7 +65,7 @@ fn exclude_by_dir_is_handled_just_like_git() { · 64 unmodified lines | ||
| 65 | 65 | let relative_path = gix_path::from_byte_slice(relative_entry); |
| 66 | 66 | let is_dir = dir.join(relative_path).metadata().ok().map(|m| m.is_dir()); |
| 67 | 67 | |
| 68 | − let platform = cache.at_entry(relative_entry, is_dir, FindError).unwrap(); | |
| 68 | + let platform = cache.at_entry(relative_entry, is_dir, &FindError).unwrap(); | |
| 69 | 69 | let match_ = platform.matching_exclude_pattern().expect("match all values"); |
| 70 | 70 | let _is_excluded = platform.is_excluded(); |
| 71 | 71 | assert_eq!( |