Debian Codegraph @

debian/missing-sources/glam-0.22.0/src/align16.rs

raw symbols SCIP
1 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
2 #[repr(C, align(16))]
3 pub(craterust-analyzer cargo glam 0.22.0 crate/) struct Align16rust-analyzer cargo glam 0.22.0 align16/Align16#<T>(pub T);
4
5 impl<T> Align16rust-analyzer cargo glam 0.22.0 align16/Align16#<T> {
6 #[allow(dead_code)]
7 pub fn as_ptrrust-analyzer cargo glam 0.22.0 align16/impl#[`Align16<T>`]as_ptr().(&self) -> *const T {
8 &self.0rust-analyzer cargo glam 0.22.0 align16/Align16#0.
9 }
10
11 #[allow(dead_code)]
12 pub fn as_mut_ptrrust-analyzer cargo glam 0.22.0 align16/impl#[`Align16<T>`]as_mut_ptr().(&mut self) -> *mut T {
13 &mut self.0rust-analyzer cargo glam 0.22.0 align16/Align16#0.
14 }
15 }
16
17 #[test]
18 fn test_align16() {
19 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/, ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/};
20 let mut a = Align16rust-analyzer cargo glam 0.22.0 align16/Align16#::<f32>(1.0);
21 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(mem::align_of_val(&a), 16);
22 unsafe {
23 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ptr::read(a.as_ptr()).to_bits(), f32::to_bits(1.0));
24 ptr::write(a.as_mut_ptr(), -1.0);
25 }
26 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.0.to_bits(), f32::to_bits(-1.0));
27 }