Skip to content

Commit

Permalink
Explain differences between const functions and const contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jul 1, 2020
1 parent 7cc2ee2 commit 167d751
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/const_eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ A _const fn_ is a function that one is permitted to call from a const context. D
`const` has no effect on any existing uses, it only restricts the types that arguments and the
return type may use, as well as prevent various expressions from being used within it.

Notable features that const contexts have, but const fn haven't are:

* floating point types
* `dyn Trait` types
* generic bounds on generic parameters beyond `Sized`
* dereferencing of raw pointers
* casting raw pointers to integers
* comparing raw pointers
* union field access

[arithmetic]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators
[array expressions]: expressions/array-expr.md
[array indexing]: expressions/array-expr.md#array-and-slice-indexing-expressions
Expand Down

0 comments on commit 167d751

Please sign in to comment.