Skip to content

time::Instant is a different size of different platforms #43332

Closed
@Thomasdezeeuw

Description

@Thomasdezeeuw

time::Instant on Linux is 16 bytes, while it is 8 bytes on MacOs. This makes it hard to assert the size of any structs using it.

Playground link

use std::mem;
use std::time::Instant;

fn assert_size<T>(want: usize) {
    assert_eq!(mem::size_of::<T>(), want);
}

fn main() {
    // This is 16 on Linux, but 8 on MacOS (and Windows?).
    assert_size::<Instant>(16);

    // This is 24 on Linux, but 16 on MacOS (and Windows?).
    assert_size::<Option<Instant>>(24);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions