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

Don't generate a mutation for .with_capacity #315

Open
sourcefrog opened this issue Mar 24, 2024 Discussed in #314 · 1 comment
Open

Don't generate a mutation for .with_capacity #315

sourcefrog opened this issue Mar 24, 2024 Discussed in #314 · 1 comment
Labels
enhancement New feature or request generate Patterns of mutation good first issue Good for newcomers

Comments

@sourcefrog
Copy link
Owner

Discussed in #314

Originally posted by pashadia March 21, 2024
Hi all,

New contributor here, first of all congratulations on a great project!

I've used cargo mutants on a fairly large codebase (12kloc). One of the things that appear regularly on my project is to preallocate memory for some data structures. For instance, we use things like let v = Vec::with_capacity(a+b);. Obviously, cargo-mutants is generating a mutation for the argument, into things like a-b or a*b. However, this won't break any tests, as it doesn't actually introduce a bug in functionality, only the memory allocation footprint may be different.

My proposal is to remove the generation of mutations for the .with_capacity parameter, for all the structs in std::collections, and perhaps not only. I would gladly attempt an implementation, if this proposal is well received.

@sourcefrog sourcefrog added enhancement New feature or request good first issue Good for newcomers generate Patterns of mutation labels Mar 24, 2024
@sourcefrog
Copy link
Owner Author

Maybe this is best done by adding a configuration for functions whose calls will not be mutated, and that could start with with_capacity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request generate Patterns of mutation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant