Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Opaque Return Type Conflict in pick_folders and pick_files Method #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mouradost
Copy link

Related to #27

Purpose

This pull request addresses an issue in the pick_folders and pick_files methods of the tauri-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 and pick_files method returns an opaque type representing an iterator of PathBuf 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 of PathBuf 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 of PathBuf items.
Implemented the PathBufIterator trait for the actual iterator type used within the pick_folders and pick_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.

@bicarlsen
Copy link
Collaborator

Is this still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants