This commit is contained in:
2025-03-26 12:41:58 -04:00
parent 637b26a0e9
commit 416dd617e6
36 changed files with 732 additions and 0 deletions

1
example_11/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

6
example_11/Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "example_11"
version = "0.1.0"
edition = "2021"
[dependencies]

14
example_11/src/main.rs Normal file
View File

@@ -0,0 +1,14 @@
use std::slice;
fn main() {
let some_vector = vec![1, 2, 3, 4];
let pointer = some_vector.as_ptr();
let length = some_vector.len();
unsafe {
let my_slice: &[u32] = slice::from_raw_parts(pointer, length);
assert_eq!(some_vector.as_slice(), my_slice);
}
}