Closed infinity0 closed 2 years ago
Note that the existing documentation, "Returns an iterator over the current result set" is insufficient; this does not explicitly say nor imply that the function also doesn't advance to the next set, so the reasonable assumption of the reader is that it does. For example, the next
function of an Iterator<Iterator<_>>
would advance to the next set as well as return an iterator over the now-current result set. The documentation of QueryResult
connotates that it is simply an Iterator<Iterator<_>>
so it's confusing.
https://github.com/blackbeam/rust-mysql-simple/blob/master/src/conn/query_result.rs#L156
This does not actually advance to the next set like repeated calls to
Iterator::next()
and other conventional methods callednext_*
. Instead, the advancing happens when iterating past the last element ofResultSet
in<QueryResult as Iterator>::next
when it callsQueryResult::handle_next
. The caller must perform this iteration even when theResultSet
is not an actual iterable result set (InSet
), but an OkPacket (InEmptySet
). This must be clearly documented, so that people don't do something incorrect like:It's also unclear why the type signature should be
Option<Result<_>>
when the function returns eitherNone
orSome(Ok(_))
, but it would be a breaking change to change that now.