about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-20 09:09:55 +0000
committerbors <bors@rust-lang.org>2018-08-20 09:09:55 +0000
commitbf1e461173e3936e4014cc951dfbdd7d9ec9190b (patch)
tree4c10135bc70233ca498e2ba5988601ef59f9f5ce /src/libsyntax/parse
parent758239c9c9e00b7c0daba6496ef246a85e7b5ce5 (diff)
parent86641d97b23674a7b0df8523a8684e8b02bf0b33 (diff)
downloadrust-bf1e461173e3936e4014cc951dfbdd7d9ec9190b.tar.gz
rust-bf1e461173e3936e4014cc951dfbdd7d9ec9190b.zip
Auto merge of #47562 - Centril:feature/core_convert_id, r=oli-obk
Add the identity function as core::convert::identity

## New notes

This implements rust-lang/rfcs#2306 (see https://github.com/rust-lang/rust/issues/53500).

## Old notes (ignore this in new reviews)

Adds the identity function `fn id<T>(x: T) -> T { x }` to core::convert and the prelude.
Some motivations for why this is useful are explained in the doc tests.
Another is that using the identity function instead of `{ x }` or `|x| x` makes it clear that you intended to use an identity conversion on purpose.

The reasoning:
+ behind adding this to `convert` and not `mem` is that this is an identity *conversion*.
+ for adding this to the prelude is that it should be easy enough to use that the ease of writing your own identity function or using a closure `|x| x` doesn't overtake that.

I've separated this out into two feature gates so that the addition to the prelude can be considered and stabilized separately.

cc @bluss
Diffstat (limited to 'src/libsyntax/parse')
0 files changed, 0 insertions, 0 deletions