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

add global functions for a full static experience #15

Merged
merged 1 commit into from
Jul 16, 2020

Conversation

ririsoft
Copy link
Contributor

Having a runtime Infer instance is only needed
when one need to add custom matchers.

Let's have a full static experience and allow
for a simpler usage.

See also #11 for the start of the discussion.

Having a 4 eyes check here would be greatly appreciated since I did a lot of copy pasting.
Cheers !

Having a runtime `Infer` instance is only needed
when one need to add custom matchers.

Let's have a full static experience and allow
for a simpler usage.
pub fn get(&self, buf: &[u8]) -> Option<Type> {
for (_, mime, ext, matcher) in self.iter_matchers() {
if matcher(buf) {
if matcher.0(buf) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having a function on WrapMatcher called like matches(buf: &[u8]) -> bool would make this code a bit clearer. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ops didn't want to send a github suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I am not a fan of the WrapMatcher solution but this is all I have for having a conf fn new(). Maybe we could address this in the work you are planing to use a struct instead of a tuple here ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can do that there. Since I already wrote it I'll have to rebase it anyway to make it use WrapMatcher https://github.com/paolobarbolini/infer/tree/refactor-1 so no problem.

Copy link
Collaborator

@paolobarbolini paolobarbolini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR 👍

@paolobarbolini paolobarbolini merged commit 8a1c022 into bojand:master Jul 16, 2020
@ririsoft ririsoft deleted the static-api branch July 16, 2020 20:53
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