Keyword auto-imported

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#

  • int
  • float
  • byte
  • bool
  • fn: 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 by new.
  • static: Declares a module-level or class-level slot shared by the whole program, or a method without self.
↑ ↓ navigate ↵ open