Skip to content

Commit 10afe13

Browse files
mbrubeckbrson
authored andcommitted
---
yaml --- r: 5975 b: refs/heads/master c: 5a0f185 h: refs/heads/master i: 5973: e9b7d80 5971: 7ff2c55 5967: 30e730a v: v3
1 parent 905d21e commit 10afe13

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 26d839216b8ca34545f05cf595c6d7044003679a
2+
refs/heads/master: 5a0f18558efc7ddb9cee6788bf74aa9876682bfa

trunk/doc/rust.texi

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,6 +2930,7 @@ effects of the expression's evaluation.
29302930
* Ref.Expr.Ret:: Expression for stopping and producing a value.
29312931
@c * Ref.Expr.Be:: Expression for stopping and executing a tail call.
29322932
* Ref.Expr.Put:: Expression for pausing and producing a value.
2933+
* Ref.Expr.As:: Expression for casting a value to a different type.
29332934
* Ref.Expr.Fail:: Expression for causing task failure.
29342935
* Ref.Expr.Log:: Expression for logging values to diagnostic buffers.
29352936
* Ref.Expr.Note:: Expression for logging values during failure.
@@ -3116,6 +3117,30 @@ either continuing execution after the @code{put} expression, or terminating its
31163117
execution and destroying the iterator frame.
31173118

31183119

3120+
@node Ref.Expr.As
3121+
@subsection Ref.Expr.As
3122+
@c * Ref.Expr.As:: Expression for casting a value to a different type.
3123+
@cindex As expression
3124+
@cindex Cast
3125+
@cindex Typecast
3126+
3127+
Executing an @code{as} expression casts the value on the left-hand side to the
3128+
type on the right-hand side.
3129+
3130+
A numeric value can be cast to any numeric type. A native pointer value can
3131+
be cast to or from any integral type or native pointer type. Any other cast
3132+
is unsupported and will fail to compile.
3133+
3134+
An example of an @code{as} expression:
3135+
@example
3136+
fn avg(v: [float]) -> float @{
3137+
let sum: float = sum(v);
3138+
let sz: float = std::vec::len(v) as float;
3139+
ret sum / sz;
3140+
@}
3141+
@end example
3142+
3143+
31193144
@node Ref.Expr.Fail
31203145
@subsection Ref.Expr.Fail
31213146
@c * Ref.Expr.Fail:: Expression for causing task failure.

0 commit comments

Comments
 (0)