diff options
| author | Corey Richardson <corey@octayn.net> | 2013-12-06 12:09:54 -0500 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2013-12-10 09:43:35 -0500 |
| commit | 0f82cbd19a0bd2d0d5e91c2fc807c7af21288eb4 (patch) | |
| tree | 24b7a6bec8532da7257b06c18bddb9e9b00bdd51 /doc/tutorial.md | |
| parent | d00a407e00a28a3607ff363cfcc1166eb4559673 (diff) | |
| download | rust-0f82cbd19a0bd2d0d5e91c2fc807c7af21288eb4.tar.gz rust-0f82cbd19a0bd2d0d5e91c2fc807c7af21288eb4.zip | |
Clarify `as`, mention transmute.
Diffstat (limited to 'doc/tutorial.md')
| -rw-r--r-- | doc/tutorial.md | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/tutorial.md b/doc/tutorial.md index 1e9b64c9e22..14dfc884122 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -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, |
