rust/src/libcollectionstest
Alex Crichton 8f6c879d2a rollup merge of #23282: nikomatsakis/fn-trait-inheritance
The primary motivation here is to sidestep #19032 -- for a time, I thought that we should improve coherence or otherwise extend the language, but I now think that any such changes will require more time to bake. In the meantime, inheritance amongst the fn traits is both logically correct *and* a simple solution to that obstacle. This change introduces inheritance and modifies the compiler so that it can properly generate impls for closures and fns.

Things enabled by this PR (but not included in this PR):

1. An impl of `FnMut` for `&mut F` where `F : FnMut` (https://github.com/rust-lang/rust/issues/23015).
2. A better version of `Thunk` I've been calling `FnBox`.

I did not include either of these in the PR because:

1. Adding the impls in 1 currently induces a coherence conflict with the pattern trait. This is interesting and merits some discussion.
2. `FnBox` deserves to be a PR of its own.

The main downside to this design is (a) the need to write impls by hand; (b) the possibility of implementing `FnMut` with different semantics from `Fn`, etc. Point (a) is minor -- in particular, it does not affect normal closure usage -- and could be addressed in the future in many ways (better defaults; convenient macros; specialization; etc). Point (b) is unfortunate but "just a bug" from my POV, and certainly not unique to these traits (c.f. Copy/Clone, PartialEq/Eq, etc). (Until we lift the feature-gate on implementing the Fn traits, in any case, there is room to correct both of these if we find a nice way.)

Note that I believe this change is reversible in the future if we decide on another course of action, due to the feature gate on implementing the `Fn` traits, though I do not (currently) think we should reverse it.

Fixes #18835.

r? @nrc
2015-03-24 14:50:44 -07:00
..
bit
btree Fallout from changing fn traits to use inheritance rather than bridge 2015-03-23 19:57:30 -04:00
bench.rs
binary_heap.rs
enum_set.rs
fmt.rs
lib.rs Test fixes and rebase conflicts, round 2 2015-03-23 17:10:19 -07:00
linked_list.rs move some tests back to libcollections 2015-03-16 21:57:42 -05:00
slice.rs std: Remove deprecated ptr functions 2015-03-21 10:16:01 -07:00
str.rs StrExt::splitn should not require a DoubleEndedSearcher 2015-03-19 19:25:22 -04:00
string.rs
vec_deque.rs std: Stabilize IteratorExt::cloned 2015-03-17 18:05:58 -07:00
vec_map.rs
vec.rs