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

Const loader without generics. #77

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

timothee-haudebourg
Copy link
Owner

This PR tackles the two last issues of the Loader trait:

  • its type parameter.
  • its mutable nature.

The type parameter is annoying because it basically bounds the loader to a specific Vocabulary implementation, but there are many cases where we want to define a loader without committing to a specific vocabulary. The result is often lots of trait bounds everywhere that could be avoided.

The fact that load takes a &mut self is completely unnecessary. None of the provided loader implementations are mutating anything when load is called. The only case where it could be useful is for a loader implementing a cache, but even then we can argue that a cache should not change the functional nature of load and should be implemented with interior mutability.

The fact that the loader must be passed with a mutable reference is annoying in many places where we could benefit from providing an immutable Copy reference.

timothee-haudebourg and others added 2 commits June 24, 2024 18:47
@timothee-haudebourg timothee-haudebourg merged commit acc3c04 into main Jun 25, 2024
2 checks passed
@timothee-haudebourg timothee-haudebourg deleted the const-loader-without-generics branch June 25, 2024 10:05
timothee-haudebourg added a commit that referenced this pull request Jun 25, 2024
Change `Loader::load` receiver from `&mut self` to `&self` (#77)
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.

None yet

1 participant