Skip to content

Improve symmetry when calling a function with a borrowed parameter #10504

Closed
@wycats

Description

@wycats

Currently, if I have a function like this:

fn hello(world: &World) {}

I can call it like this:

hello(~World{})

But not like this:

hello(World{})

// I would have to do
hello(&World{})

According to @alexcrichton, this is because the first example automatically coerces the ~World into a &~World, but the second example does not.

The lack of symmetry here is somewhat confusing, and makes it hard to understand (at least at first), how exactly borrowed pointers work with different callers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions