logo
  • 教程列表
  • SO官方文檔
  • 原始指標
    • 建立和使用常量原始指標
    • 建立和使用可變原始指標
    • 將原始指標初始化為 null
    • 連鎖提領
    • 顯示原始指標
  1. StackOverflow 文件
  2. Rust 教程
  3. 原始指標
  4. 將原始指標初始化為 null

將原始指標初始化為 null

Created: November-22, 2018

與普通的 Rust 引用不同,允許原始指標採用空值。

use std::ptr;

// Create a const NULL pointer
let null_ptr: *const u16 = ptr::null();

// Create a mutable NULL pointer
let mut_null_ptr: *mut u16 = ptr::null_mut();
  • 連鎖提領
  • 建立和使用可變原始指標

Copyright © 2018. All right reserved

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

  • 關於本站
  • 免責聲明