Add a count method to Source #329
No reviewers
Labels
No labels
bug
duplicate
easy
enhancement
help wanted
invalid
question
rfc
structured-logging
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-rust-lang/log!329
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/source-count"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds a
Source::count(&self) -> usizemethod to figure out how many key-value pairs to expect.I've also tried to clarify the expectation that subsequent calls to
Source::visitwill yield the same key-value pairs unless the visitor fails. A buggySource::visitwith the default implementation ofcountmay yield a different number of key-value pairs. Given that, we could make the method something likeSource::size_hint(&self) -> Option<usize>instead, but I think the fundamental requirement thatSource::visitpasses the same pairs to the visitor unless the visitor itself fails is reasonable and lets us add more useful methods likefor_eachthat don't have to return results. The reasonvisititself is fallible is so that a formatting or serialization error can be passed upstream for a logging framework to surface in some way.r? @Thomasdezeeuw
Looks good to me.