Skip to content

Documentation shows prototype of a function which is different from actual usage syntax #18889

@kornelski

Description

@kornelski

http://doc.rust-lang.org/std/mem/fn.size_of.html

Displays size_of as:

pub fn size_of<T>() -> uint

which I've tried to use as:

std::mem::size_of<T>();

but to my surprise it didn't work. For reasons I don't quite understand the compiler accepts std::mem::size_of::<T>() (with extra ::).

I bet there's a very good reason why the syntax is like that, but it's non-obvious.

I wish the documentation was very clear about this (e.g. contained usage example or a note explaining the syntax).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions