logo
  • 教程列表
  • SO官方文檔
  • 全域性
    • 常量
    • 靜態的
    • 懶惰的
    • 執行緒區域性物件
    • 使用 mut static 的安全靜態 mut
  1. StackOverflow 文件
  2. Rust 教程
  3. 全域性
  4. 靜態的

靜態的

Created: November-22, 2018

static 關鍵字宣告瞭一個全域性靜態繫結,它可能是可變的。

static HELLO_WORLD: &'static str = "Hello, world!";

fn main() {
    println("{}", HELLO_WORLD);
}

這輸出

Hello, world!
  • 懶惰的
  • 常量

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明