Update const-fn doc in unstable-book
Update src/doc/unstable-book/src/language-features/const-fn.md Co-authored-by: Ivan Tham <pickfire@riseup.net>
This commit is contained in:
parent
5019791e2d
commit
caab16fa20
@ -6,24 +6,5 @@ The tracking issue for this feature is: [#57563]
|
||||
|
||||
------------------------
|
||||
|
||||
The `const_fn` feature allows marking free functions and inherent methods as
|
||||
`const`, enabling them to be called in constants contexts, with constant
|
||||
arguments.
|
||||
|
||||
## Examples
|
||||
|
||||
```rust
|
||||
#![feature(const_fn)]
|
||||
|
||||
const fn double(x: i32) -> i32 {
|
||||
x * 2
|
||||
}
|
||||
|
||||
const FIVE: i32 = 5;
|
||||
const TEN: i32 = double(FIVE);
|
||||
|
||||
fn main() {
|
||||
assert_eq!(5, FIVE);
|
||||
assert_eq!(10, TEN);
|
||||
}
|
||||
```
|
||||
The `const_fn` feature enables additional functionality not stabilized in the
|
||||
[minimal subset of `const_fn`](https://github.com/rust-lang/rust/issues/53555)
|
||||
|
Loading…
x
Reference in New Issue
Block a user