M
Size: a a a
M
G
M
G
M
M
G
#![feature(const_generics)]
struct Foo<T, const N: usize> {
array: [T; N],
first: *mut T,
}
fn consume(foo: Foo<i32, 3>) {
unsafe { *foo.first = 12i32 };
}
fn main() {
let mut array = [1, 2, 3];
let first = array.as_mut_ptr();
let foo = Foo {
array, first
};
unsafe { *foo.first = 22i32 };
consume(foo);
}
M
M
#![feature(const_generics)]
struct Foo<T, const N: usize> {
array: [T; N],
first: *mut T,
}
fn consume(foo: Foo<i32, 3>) {
unsafe { *foo.first = 12i32 };
}
fn main() {
let mut array = [1, 2, 3];
let first = array.as_mut_ptr();
let foo = Foo {
array, first
};
unsafe { *foo.first = 22i32 };
consume(foo);
}
M
G
M
G
M
M
G
G
G
СВ