Skip to content

Idea for hashing pointers to unsized types #2

@durka

Description

@durka

Can this trick (essentially, compare sizeof &T::Target to sizeof usize) be used to eliminate the FIXME?

by_address/src/lib.rs

Lines 134 to 138 in 3bdda92

fn hash<H: Hasher>(&self, state: &mut H) {
// FIXME: For fat pointers to dynamically-sized types, this discards the extra data (vtable
// pointer or length), so it may have a high collision rate in certain cases.
(self.addr() as *const ()).hash(state)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions