Clarify as, mention transmute.

This commit is contained in:
Corey Richardson 2013-12-06 12:09:54 -05:00
parent d00a407e00
commit 0f82cbd19a

View file

@ -361,17 +361,19 @@ Rust's set of operators contains very few surprises. Arithmetic is done with
also a unary prefix operator that negates numbers. As in C, the bitwise operators
`>>`, `<<`, `&`, `|`, and `^` are also supported.
Note that, if applied to an integer value, `!` flips all the bits (like `~` in
C).
Note that, if applied to an integer value, `!` flips all the bits (bitwise
NOT, like `~` in C).
The comparison operators are the traditional `==`, `!=`, `<`, `>`,
`<=`, and `>=`. Short-circuiting (lazy) boolean operators are written
`&&` (and) and `||` (or).
For type casting, Rust uses the binary `as` operator. It takes an
expression on the left side and a type on the right side and will,
if a meaningful conversion exists, convert the result of the
expression to the given type.
For compile-time type casting, Rust uses the binary `as` operator. It takes
an expression on the left side and a type on the right side and will, if a
meaningful conversion exists, convert the result of the expression to the
given type. Generally, `as` is only used with the primitive numeric types or
pointers, and is not overloadable. [`transmute`][transmute] can be used for
unsafe C-like casting of same-sized types.
~~~~
let x: f64 = 4.0;
@ -379,6 +381,8 @@ let y: uint = x as uint;
assert!(y == 4u);
~~~~
[transmute]: http://static.rust-lang.org/doc/master/std/cast/fn.transmute.html
## Syntax extensions
*Syntax extensions* are special forms that are not built into the language,