File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 6
6
# Summary
7
7
[ summary ] : #summary
8
8
9
- Adds an identity function ` pub fn identity<T>(x: T) -> T { x } ` as
9
+ Adds an identity function ` pub const fn identity<T>(x: T) -> T { x } ` as
10
10
` core::convert::identity ` . The function is also re-exported to
11
11
` std::convert::identity ` as well as the prelude of
12
12
both libcore and libstd.
@@ -148,7 +148,7 @@ all `Sized` types in Rust into libcore at the module `core::convert` and
148
148
defines it as:
149
149
150
150
``` rust
151
- pub fn identity <T >(x : T ) -> T { x }
151
+ pub const fn identity <T >(x : T ) -> T { x }
152
152
```
153
153
154
154
This function is also re-exported to ` std::convert::identity ` as well as
@@ -160,8 +160,8 @@ moved since Rust uses move semantics by default.
160
160
# Reference-level explanation
161
161
[ reference-level-explanation ] : #reference-level-explanation
162
162
163
- An identity function defined as ` pub fn identity<T>(x: T) -> T { x } ` exists as
164
- ` core::convert::identity ` . The function is also re-exported as
163
+ An identity function defined as ` pub const fn identity<T>(x: T) -> T { x } `
164
+ exists as ` core::convert::identity ` . The function is also re-exported as
165
165
` std::convert::identity ` as well as the prelude of both libcore and libstd.
166
166
167
167
Note that the identity function is not always equivalent to a closure
You can’t perform that action at this time.
0 commit comments