2016-03-20 29 views
0

我使用ptr::set_memorythe std module未解決的名稱錯誤使用std ::時PTR :: set_memory

use std::ptr; 

fn main() { 
    let addr = 0 as *mut u8; 
    unsafe { ptr::set_memory(addr, 0, 8); } 
} 

但程序不會編譯由於這個錯誤:

src/main.rs:160:18: 160:33 error: unresolved name `ptr::set_memory` [E0425] 
src/main.rs:160   unsafe { ptr::set_memory(p, 0, total_size); } 
           ^~~~~~~~~~~~~~~ 
+2

如果您不顯示代碼,我們也不能。請提供[MCVE](https://stackoverflow.com/help/mcve)。 – starblue

+0

@starblue足夠公平,它似乎發生與任何使用該功能,但。已編輯顯示僅使用問題調用的新項目。 –

回答

1

的問題在於你意外地使用了過時的非官方文檔。 ptr::set_memory不是std的一部分。使用the official documentation

相關問題