maybe include a doc-comment here stating whether the `end` here is an inclusive or exclusive bound?  (I know the rustc doc comments are not great.  (Also we might consider making this helper a non-pub function.)