summaryrefslogtreecommitdiffstats
path: root/src/doc/book/redirects/casting-between-types.md
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/doc/book/redirects/casting-between-types.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/doc/book/redirects/casting-between-types.md b/src/doc/book/redirects/casting-between-types.md
new file mode 100644
index 000000000..7e1eb7744
--- /dev/null
+++ b/src/doc/book/redirects/casting-between-types.md
@@ -0,0 +1,32 @@
+% Casting between types
+
+<small>There is a new edition of the book and this is an old link.</small>
+
+> A type cast expression is denoted with the binary operator `as`.
+> Executing an `as` expression casts the value on the left-hand side to the type on the right-hand side.
+
+```rust
+# fn sum(values: &[f64]) -> f64 { 0.0 }
+# fn len(values: &[f64]) -> i32 { 0 }
+
+fn average(values: &[f64]) -> f64 {
+ let sum: f64 = sum(values);
+ let size: f64 = len(values) as f64;
+ sum / size
+}
+```
+
+---
+
+Here are the relevant sections in the new and old books:
+
+* **[in the current edition: Appendix A — Keywords][2]**
+* [In the Rust Reference: Type Cast Expressions][3]
+* [In the Rust documentation: `mem::transmute`][4]
+* <small>[In the first edition: Ch 3.29 — Casting between types][1]</small>
+
+
+[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/casting-between-types.html
+[2]: appendix-01-keywords.html
+[3]: ../reference/expressions/operator-expr.html#type-cast-expressions
+[4]: ../std/mem/fn.transmute.html \ No newline at end of file