Skip to content

Commit 549bc0b

Browse files
committed
Add a Porting Reminders section to the README
1 parent 7811f92 commit 549bc0b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ See [rust-lang/rust#35437][0].
2424
[2]: https://github.com/rust-lang/compiler-rt/tree/8598065bd965d9713bfafb6c1e766d63a7b17b89/lib/builtins
2525
[3]: https://travis-ci.org/japaric/rustc-builtins
2626

27+
### Porting Reminders
28+
29+
1. [Rust][4] and [C][5] have slightly different operator precedence. C evaluates comparisons (`== !=`) before bitwise operations (`& | ^`), while Rust evaluates the other way.
30+
2. C assumes wrapping operations everywhere. Rust panics on overflow when in debug mode. Consider using the [Wrapping][6] type or the explicit [wrapping_*][7] functions where applicable.
31+
3. Note [C implicit casts][8], especially integer promotion. Rust is much more explicit about casting, be sure that any cast which affects the output is ported to the Rust implementation.
32+
4. Rust has [many functions][9] for integer or floating point manipulation in the standard library. Consider using one of these functions rather than porting a new one.
33+
34+
[4]: https://doc.rust-lang.org/reference.html#operator-precedence
35+
[5]: http://en.cppreference.com/w/c/language/operator_precedence
36+
[6]: https://doc.rust-lang.org/core/num/struct.Wrapping.html
37+
[7]: https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_add
38+
[8]: http://en.cppreference.com/w/cpp/language/implicit_conversion
39+
[9]: https://doc.rust-lang.org/std/primitive.i32.html
40+
2741
## Progress
2842

2943
- [x] adddf3.c

0 commit comments

Comments
 (0)