From a60089903a54682a96646f13ee6e8b8a406621be Mon Sep 17 00:00:00 2001 From: Steve Klabnik <steve@steveklabnik.com> Date: Sun, 8 Mar 2015 10:34:00 -0400 Subject: [PATCH] Add note about pre/post increment to the design FAQ. Fixes #14686 --- src/doc/complement-design-faq.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/doc/complement-design-faq.md b/src/doc/complement-design-faq.md index e57953db3a2..3edbcbe62c5 100644 --- a/src/doc/complement-design-faq.md +++ b/src/doc/complement-design-faq.md @@ -174,3 +174,10 @@ bindings. See also [a long thread][alt] on renaming `let mut` to `var`. [alt]: https://mail.mozilla.org/pipermail/rust-dev/2014-January/008319.html + +## Why no `--x` or `x++`? + +Preincrement and postincrement, while convenient, are also fairly complex. They +require knowledge of evaluation order, and often lead to subtle bugs and +undefined behavior in C and C++. `x = x + 1` or `x += 1` is only slightly +longer, but unambiguous.