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

feat: use Box<dyn> in sparse functions #39

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,9 @@ impl<T: ArtifactOutput> Project<T> {
/// let output = project.compile_sparse(|path: &Path| path.ends_with("Greeter.sol")).unwrap();
/// # }
/// ```
pub fn compile_sparse<F: FileFilter + 'static>(
&self,
filter: F,
) -> Result<ProjectCompileOutput<T>> {
pub fn compile_sparse(&self, filter: Box<dyn FileFilter>) -> Result<ProjectCompileOutput<T>> {
let sources =
Source::read_all(self.paths.input_files().into_iter().filter(|p| filter.is_match(p)))?;
let filter: Box<dyn FileFilter> = Box::new(filter);

#[cfg(all(feature = "svm-solc", not(target_arch = "wasm32")))]
if self.auto_detect {
Expand Down
5 changes: 1 addition & 4 deletions src/project_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ impl<T: ArtifactOutput> TempProject<T> {
self.project().compile()
}

pub fn compile_sparse<F: FileFilter + 'static>(
&self,
filter: F,
) -> Result<ProjectCompileOutput<T>> {
pub fn compile_sparse(&self, filter: Box<dyn FileFilter>) -> Result<ProjectCompileOutput<T>> {
self.project().compile_sparse(filter)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ fn can_compile_sparse_with_link_references() {
)
.unwrap();

let mut compiled = tmp.compile_sparse(TestFileFilter::default()).unwrap();
let mut compiled = tmp.compile_sparse(Box::<TestFileFilter>::default()).unwrap();
compiled.assert_success();

let mut output = compiled.clone().output();
Expand Down