]> git.lizzy.rs Git - rust.git/commit
Reduce the genericity of closures in the iterator traits
authorJosh Stone <jistone@redhat.com>
Sat, 6 Jul 2019 01:06:06 +0000 (18:06 -0700)
committerJosh Stone <jistone@redhat.com>
Mon, 12 Aug 2019 22:03:44 +0000 (15:03 -0700)
commite67620afc4a5b22960a5f1b056cbc4b878beb2e8
treea02ebb807188b0cdd044eb2ddd1964fd92d73396
parent60960a260f7b5c695fd0717311d72ce62dd4eb43
Reduce the genericity of closures in the iterator traits

By default, closures inherit the generic parameters of their scope,
including `Self`. However, in most cases, the closures used to implement
iterators don't need to be generic on the iterator type, only its `Item`
type. We can reduce this genericity by redirecting such closures through
local functions.

This does make the closures more cumbersome to write, but it will
hopefully reduce duplication in their monomorphizations, as well as
their related type lengths.
src/libcore/iter/traits/accum.rs
src/libcore/iter/traits/double_ended.rs
src/libcore/iter/traits/iterator.rs