官术网_书友最值得收藏!

  • Mastering Rust
  • Rahul Sharma Vesa Kaihlavirta
  • 179字
  • 2021-07-02 13:35:14

Primitive types

Rust has the following built-in primitive types:

  • bool: These are the usual booleans and can be either true or false .
  • char: Characters, such as e.
  • Integer types: These are characterized by the bit width. Rust supports integers that are up to 128 bits wide:
  • isize: The pointer-sized signed integer type. Equivalent to i32 on 32-bit CPU and i64 on 64-bit CPU.
  • usize: The pointer-sized unsigned integer type. Equivalent to i32 on 32-bit CPU and i64 on 64-bit CPU.
  • f32: The 32-bit floating point type. Implements the IEEE 754 standard for floating point representation.
  • f64: The 64-bit floating point type.
  • [T; N]: A fixed-size array, for the element type, T, and the non-negative compile-time constant size N.
  • [T]: A dynamically-sized view into a contiguous sequence, for any type T.
  • str: String slices, mainly used as a reference, that is, &str.
  • (T, U, ..): A finite sequence, (T, U, ..) where T and U can be different types.
  • fn(i32) -> i32: A function that takes an i32 and returns an i32. Functions also have a type.
主站蜘蛛池模板: 施甸县| 和静县| 嘉峪关市| 安平县| 靖远县| 高台县| 奈曼旗| 神木县| 嘉禾县| 崇礼县| 安顺市| 绍兴市| 安西县| 库尔勒市| 镇平县| 高台县| 通道| 荥经县| 嘉荫县| 石首市| 尖扎县| 车致| 瑞金市| 栖霞市| 翁牛特旗| 明溪县| 苏州市| 颍上县| 丹阳市| 宣化县| 略阳县| 枞阳县| 平湖市| 财经| 西吉县| 西乡县| 社旗县| 台南县| 昭觉县| 无极县| 大邑县|