Fixing Opaque Return Type Conflict in pick_folders
and pick_files
Method
#28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #27
Purpose
This pull request addresses an issue in the
pick_folders
andpick_files
methods of thetauri-sys
crate, where a conflicting opaque return type is causing build failures. The changes proposed here aim to resolve the conflict and ensure the method returns a consistent and correct opaque type.Problem
The current implementation of the
pick_folders
andpick_files
method returns an opaque type representing an iterator ofPathBuf
items. However, the closure passed to the map function within the method is causing a mismatch in the concrete return type for the same opaque type, leading to a build failure.Solution
To fix the conflict, we have explicitly defined a trait,
PathBufIterator
, to represent the iterator ofPathBuf
items. We have then implemented this trait for the actual iterator type,std::vec::IntoIter<PathBuf>
, used within the method. By wrapping the closure inside a function that returns a trait object (Box<dyn PathBufIterator>
), we ensure a consistent return type for the opaque type, resolving the conflict.Proposed Changes
Introduced the
PathBufIterator
trait to represent the iterator ofPathBuf
items.Implemented the
PathBufIterator
trait for the actual iterator type used within thepick_folders
andpick_files
methods.Modified the closure passed to the map function to explicitly return a trait object (
Box<dyn PathBufIterator>
).Testing
The crate
tauri-sys
has been build and tested on the three operating systems (Windows, Ubuntu, and macOS). The tests verify that the method returns the correct iterator and that it integrates seamlessly with the existing codebase.Documentation
Only comments are provided. However, if the pull request get accepted I will provide proper documentation.