Navigation Menu

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 {Event,Op}.Has() #477

Merged
merged 1 commit into from Jul 30, 2022
Merged

Add {Event,Op}.Has() #477

merged 1 commit into from Jul 30, 2022

Conversation

arp242
Copy link
Member

@arp242 arp242 commented Jul 30, 2022

Using:

if event.Op&fsnotify.Create == fsnotify.Create {
}

is overly verbose and awkward; a Has() method makes this much nicer:

if event.Has(fsnotify.Create) {
}

PR #76 was previously rejected; I think that HasCreate() etc. is
overkill, but a Has() method makes the library quite a bit more
convenient IMO.

I added it to both the Event and Op to avoid confusion; with this we can
change the Op field to be private in a future v2.

Fixes #107

Using:

	if event.Op&fsnotify.Create == fsnotify.Create {
	}

is overly verbose and awkward; a Has() method makes this much nicer:

	if event.Has(fsnotify.Create) {
	}

PR #76 was previously rejected; I think that HasCreate() etc. is
overkill, but a Has() method makes the library quite a bit more
convenient IMO.

I added it to both the Event and Op to avoid confusion; with this we can
change the Op field to be private in a future v2.

Fixes #107
@arp242 arp242 requested a review from a team July 30, 2022 12:29
Copy link
Member

@bep bep left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@arp242 arp242 merged commit 57e6a49 into main Jul 30, 2022
@arp242 arp242 deleted the has branch July 30, 2022 15:28
@KiddoV
Copy link

KiddoV commented Aug 23, 2022

What version does the method event.Has() available? It is undefined on v1.5.4.

@arp242
Copy link
Member Author

arp242 commented Aug 23, 2022

It's not yet in any released version.

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.

Documentation on how to use Op and bitwise logic
4 participants