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

  • 关于我们
  • 免责声明