Skip to content

Commit 0f82cbd

Browse files
committed
Clarify as, mention transmute.
1 parent d00a407 commit 0f82cbd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

doc/tutorial.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,24 +361,28 @@ Rust's set of operators contains very few surprises. Arithmetic is done with
361361
also a unary prefix operator that negates numbers. As in C, the bitwise operators
362362
`>>`, `<<`, `&`, `|`, and `^` are also supported.
363363

364-
Note that, if applied to an integer value, `!` flips all the bits (like `~` in
365-
C).
364+
Note that, if applied to an integer value, `!` flips all the bits (bitwise
365+
NOT, like `~` in C).
366366

367367
The comparison operators are the traditional `==`, `!=`, `<`, `>`,
368368
`<=`, and `>=`. Short-circuiting (lazy) boolean operators are written
369369
`&&` (and) and `||` (or).
370370

371-
For type casting, Rust uses the binary `as` operator. It takes an
372-
expression on the left side and a type on the right side and will,
373-
if a meaningful conversion exists, convert the result of the
374-
expression to the given type.
371+
For compile-time type casting, Rust uses the binary `as` operator. It takes
372+
an expression on the left side and a type on the right side and will, if a
373+
meaningful conversion exists, convert the result of the expression to the
374+
given type. Generally, `as` is only used with the primitive numeric types or
375+
pointers, and is not overloadable. [`transmute`][transmute] can be used for
376+
unsafe C-like casting of same-sized types.
375377

376378
~~~~
377379
let x: f64 = 4.0;
378380
let y: uint = x as uint;
379381
assert!(y == 4u);
380382
~~~~
381383

384+
[transmute]: http://static.rust-lang.org/doc/master/std/cast/fn.transmute.html
385+
382386
## Syntax extensions
383387

384388
*Syntax extensions* are special forms that are not built into the language,

0 commit comments

Comments
 (0)