You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trait Position {}
struct Coordinates(f64, f64);
impl Position for Coordinates {}
fn main() {
let val = Coordinates(1.0, 2.0);
let ref_: &Coordinates = &val;
let pos_ref: &Position = &val as &Position;
let ptr: *const Coordinates = &val as *const Coordinates;
let pos_ptr: *const Position = &val as *const Position;
println!("ref_: {}", std::mem::size_of_val(&ref_));
println!("ptr: {}", std::mem::size_of_val(&ptr));
println!("val: {}", std::mem::size_of_val(&val));
println!("pos_ref: {}", std::mem::size_of_val(&pos_ref));
println!("pos_ptr: {}", std::mem::size_of_val(&pos_ptr));
}
size of value and position in memory. About alignment see here.
On the side, is there a way we can use const fn somewhere if the custom traits to have it computed at compile-time?
The text was updated successfully, but these errors were encountered:
Run a check using
std::mem
to check for example:size of value and position in memory. About alignment see here.
On the side, is there a way we can use
const fn
somewhere if the custom traits to have it computed at compile-time?The text was updated successfully, but these errors were encountered: