as
Source: compiler/src/builtin_docs/keywords.md Renames an import, or converts a value between primitive types.
In use path::item as alias;, the item is bound as alias. In an
expression, x as T converts between int, float, byte and bool;
float as int truncates toward zero.
use io::sync::{println as say};
fn main() {
let n = 7.9 as int; // 7
let f = 3 as float; // 3.0
let _ = say("done");
}
See also#
intfloatbyteboolfn: Declares a function, a method, or (written in an expression) an anonymous function.let: Declares a mutable local variable.const: Declares a binding that cannot be reassigned: a local, a module constant, or a class field that is set only bynew.static: Declares a module-level or class-level slot shared by the whole program, or a method withoutself.