-
Notifications
You must be signed in to change notification settings - Fork 88
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
FileHandle.read() should have a discardable result #57
Comments
You can silence the warning like this: _ = command.stdout.read() |
I realize that I can do that. I could also just continue to ignore it since it doesn't break anything. ;) I don't want to just silence/ignore warnings though. If a return value can be reasonably expected not to be used, like the result of There are numerous examples of other frameworks and blog posts recommending that instead of doing: _ = command.stdout.read() like you're suggesting, to just mark the method with References: It's always better to fix things that cause compiler warnings at the source rather than force developers to work around them. If you're saying that in order for this framework to work, we HAVE to call I'm happy to make the change myself and submit a pull request, but I would like your input on whether you think that all of the read variants should also be marked. |
Yes I see your point. But I referred to the wrong method in that issue. I should have said |
Ahh, sorry for the confusion/rant. I will update my code to use |
No problem, it's good to have users that care about the usability of the framework. And thank you for your pull request, I just merged it. |
In #54 The fix to #52 was to call .read() on the pipes before calling .finish(). When manually managing an AsyncCommand, the fixit is to call .read() "even if you're not going to use the result". I think that this should warrant the .read() function being marked with the
@discardableResult
attribute.Currently in my code, before calling
command.exitcode()
I have a line that looks like this:This line generates a warning when building.
I'm unsure if the readSome(), readData(), and readSomeData() variants should be marked as
@discardableResult
as well.The text was updated successfully, but these errors were encountered: