Skip to content

Commit

Permalink
Rust unstable book: basic desc and example for const_fn.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Mar 14, 2017
1 parent fd182c4 commit e06c515
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cargo
19 changes: 19 additions & 0 deletions src/doc/unstable-book/src/const-fn.md
Expand Up @@ -6,5 +6,24 @@ The tracking issue for this feature is: [#24111]

------------------------

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);
}
```

0 comments on commit e06c515

Please sign in to comment.