···
extern crate alloc;
use alloc::vec::Vec;
use core::mem::ManuallyDrop;
use log::info;
use uefi::println;
pub static mut gbuf:&'static mut [i32] = &mut [0; 0x1000];
pub fn testdumphex() -> i32 {
info!("testdumphex!");
let mut hexvec = Vec::new();
for i in 1...10 {
hexvec.push(i);
}
for (pos, chr) in hexvec.iter().enumerate() {
println!("idx {},val {:x}!", pos, chr);
}
0
}
pub fn testdumphexptr() -> i32 {
info!("testdumphexptr!");
let mut hexvec = Vec::with_capacity(0x10);
for i in 1...10 {
hexvec.push(i);
}
let len=hexvec.len();
let cap=hexvec.capacity();
let mut hexvecv = ManuallyDrop::new(hexvec.clone());
let mut hexptr = hexvecv.as_mut_ptr();
unsafe {
let rebuilt = Vec::from_raw_parts(hexptr,len , cap);
for (pos, chr) in rebuilt.iter().enumerate() {
println!("idx {},val {:x}!", pos, chr);
}
// gbuf.append(hexvec.as_mut());
for (pos, chr) in hexvec.iter().enumerate() { gbuf[pos]=*chr;
}
for i in 0...len{
let chr= gbuf[i];
let pos=i;
println!("gbuf idx {},val {:x}!", pos, chr);
}
}
info!("testdumphexptr end!");
0
}
···
···