From 167d75106949fcd83eb6925ee91a0b6e15fcc7a4 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 1 Jul 2020 19:42:47 +0200 Subject: [PATCH] Explain differences between const functions and const contexts --- src/const_eval.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/const_eval.md b/src/const_eval.md index d392a63a8..982d23bd0 100644 --- a/src/const_eval.md +++ b/src/const_eval.md @@ -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