Skip to content

auto-borrow and consistent behavior of pointers #13988

Closed
@oblitum

Description

@oblitum

auto-deref has been added but I'm still interested in a more uniform behavior of custom pointers (meaning the ones that exist by trait implementation) and native ones (like the dying ~T).

An example situation:

use std::rc::Rc;

struct Bar { x: int }

fn foo(p: &int) {
    println!("{}", p);
}

fn baz(p: &Bar) {
    println!("{}", p.x);
}

fn main() {
    let pi = box 10;
    let pb = Rc::new(Bar {x: 3});
    foo(pi);
    // this still doesn't auto borrow:
    //baz(pb);
    // although this works:
    println!("{}", pb.x);
}

I've looked in #7141, #12491, #13542, #5527, #12825, #12610 and RFC 59 but could not grasp whether any would be addressing this or whether it's desirable, sorry if it's a duplicate.

Activity

steveklabnik

steveklabnik commented on Jan 23, 2015

@steveklabnik
Member

Closing in favor of the linked RFC issue.

added a commit that references this issue on Feb 13, 2023

Auto merge of rust-lang#13988 - Veykril:hover-no-markdown, r=Veykril

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @steveklabnik@oblitum

        Issue actions

          auto-borrow and consistent behavior of pointers · Issue #13988 · rust-lang/rust