RangeXxx<&T> should implement RangeBounds<T> even if T is unsized #107196
Labels
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: This should compile since
BTreeMap::range
is supposed to accept aRangeBounds
with an unsized type parameterInstead, this happened: It does not compile with the error:
This is because
Range<&str>
does not implementRangeBounds<str>
, because the currentimpl RangeBounds<str> for Range<&str>
is as follows:Similarly, for other range structs except
(Bound, Bound)
andRangeFull
(the latter of which does not have a type anyway), the type parameter is unnecessarily constrained to be sized:The implicit
Sized
bound onT
for theRangeXxx<&T>
cases appears to be unintentional judging from the fact that there are no comments explaining this decision.Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: