-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Implement size_hint on various sys iterators #49552
Conversation
Continuation of rust-lang#49205
Ping from triage, @Kimundi ! |
Ping from triage! Can @Kimundi (or someone else from @rust-lang/libs) review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay.
- I assume the
(0, Some(0))
size_hints are for platforms where no sensible implementation is possible? Could you explain real quick why this is the case for each of the platforms? - Two of the size_hints seem to iterate over the internal iterator. I'm not currently aware if that's a thing we do at other places, or wether we try hard to just do constant-time operations in them. Could you explain why you implemented it like this?
src/libstd/sys/windows/os.rs
Outdated
// There will be at most N + 1 entries, where N is the number of | ||
// remaining semicolons. | ||
let data = self.data.clone(); | ||
let semicolons = data.filter(|b| b == (';' as u16)).count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, is it a good idea for the size_hint calculation to actually iterate over the data? Or am I misunderstanding what is happening here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely controversial / not obvious. My motivation to iterate over the data to calculate the size is because, in this case, we have a static guarantee that the thing being iterated over is in-memory, and that iterating over it will have no side-effects. Further, the iterator is over the number of entries in a directory, which is inherently bounded; and it's particularly common to collect the result of a dir entry iterator.
.count(); | ||
let lower = upper.saturating_sub(2); | ||
(lower, Some(upper)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question about iteration here.
The |
Ping from triage @Kimundi! The PR author replied to you. |
@bors r+ |
📌 Commit e50fb63 has been approved by |
⌛ Testing commit e50fb63 with merge 94d38d4155c12531f6d8e98fc851a7bdc7b046d2... |
💔 Test failed - status-appveyor |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry |
Still waiting on bors... |
@bors r=Kimundi |
📌 Commit 29ec498 has been approved by |
⌛ Testing commit 29ec498 with merge 80e787ba93870b7474a2f406fcd7e3ff22ad0f11... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
1 similar comment
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@TimNN duplicate posts I'll look into the errors when I have time |
Weekly ping from triage @Phlosioneer! Will you be able to look into the errors soon? |
Thank you for this PR @Phlosioneer! Unfortunately we haven't heard from you on this in a while, so I'm closing the PR to keep things tidy. Don't worry though, if you'll have time again in the future please reopen this PR, we'll be happy to review it again! |
Continuation of #49205