-
Rust 1.61.0 ❤️__<[T]>::as_mut_ptr_range코딩Coding/Rust☑︎Release☀︎Notes_New◎Version 2022. 6. 29. 00:45728x90
fn main (){ let a = [1, 2, 3]; let x = &a[1] as *const _; let y = &5 as *const _; println!("{:?}", a.as_ptr_range()); // .contains(&x)); // assert!(!a.as_ptr_range().contains(&y)); }
결과
Standard Error Compiling playground v0.0.1 (/playground) warning: unused variable: `x` --> src/main.rs:3:9 | 3 | let x = &a[1] as *const _; | ^ help: if this is intentional, prefix it with an underscore: `_x` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `y` --> src/main.rs:4:9 | 4 | let y = &5 as *const _; | ^ help: if this is intentional, prefix it with an underscore: `_y` warning: `playground` (bin "playground") generated 2 warnings Finished dev [unoptimized + debuginfo] target(s) in 1.11s Running `target/debug/playground` Standard Output 0x7ffec04ae47c..0x7ffec04ae488
fn main (){ let a = [1, 2, 3]; let x = &a[1] as *const _; let y = &5 as *const _; println!("{:?}", a.as_ptr_range().contains(&x)); // assert!(!a.as_ptr_range().contains(&y)); }
결과
Compiling playground v0.0.1 (/playground) warning: unused variable: `y` --> src/main.rs:4:9 | 4 | let y = &5 as *const _; | ^ help: if this is intentional, prefix it with an underscore: `_y` | = note: `#[warn(unused_variables)]` on by default warning: `playground` (bin "playground") generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 0.74s Running `target/debug/playground` Standard Output true
https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_mut_ptr
반응형'코딩Coding > Rust☑︎Release☀︎Notes_New◎Version' 카테고리의 다른 글
Rust 1.62❤️에서 최적화 된 std::sync::Mutex, RwLock, 겁나게 빨라짐. (0) 2022.07.11 Rust❤️1.63 아주 기대가 많이 되는 3가지 기능 (0) 2022.07.10 RLS Deprecation | Rust Blog - 결국은 rust analyst 가 win❤️ 역시 강한 놈만 살아 남는다 ㅋ (0) 2022.07.02 Announcing Rust 1.62.0__❤️How does the new Mutex implementation compare to parking_lot? (0) 2022.07.01 Rust 2021 edition❤️에서는 Rust 2018 edition에서 써 온 extern crate란 문법을 쓰지 않아요❤️ (0) 2022.06.27 awesome Rust ❤️- 러스트 최신 정보 얻기 (0) 2022.06.26 Rust 1.63에서 생기는 멋진 기능들 (0) 2022.06.26 Rust 1.63: Scoped Threads (0) 2022.06.19