Skip to content

Make cloned values indistinguishable #1544

Open
@Stebalien

Description

@Stebalien

Define "Returns a copy of the value" to mean a == b -> a == b.clone().


Original unworkable proposal (see discussion below):

Currently, clone explicitly doesn't guarantee that the following are always indistinguishable:

let a = f();
let b = g();
let c = b.clone();
h(a, b);
let a = f();
let b = g();
let c = b.clone();
h(a, c);

This is unfortunate. However, the trait does say that Clone::clone() "Returns a copy of the value." which could imply indistinguishably (i.e., a copy of a value is indistinguishable from the original). It would be nice to make this explicit (so that, e.g., a == b implies a == b.clone()).

/cc #1203

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-docRelevant to the documentation team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions