Implicit cloning is a non-starter. Clones can be very expensive.
Hiding that cost is undesirable and would require adding Clone to the
language (it's currently a normal library feature).

On Thu, Jun 12, 2014 at 10:46 AM, Tommi <[email protected]> wrote:
> `Copy` types aren't really relevant to a discussion about adding to Rust the 
> C++ like optimization of moving rvalues (of non-Copy types) when they're 
> passed to certain functions.
>
> On 2014-06-12, at 20:30, Corey Richardson <[email protected]> wrote:
>
>> It's called Copy. `trait Foo: Copy { ... }`.
>>
>> On Thu, Jun 12, 2014 at 10:26 AM, Tommi <[email protected]> wrote:
>>> I think a new keyword, something like `stable`, is needed for specifying 
>>> that an argument passed to a trait function is guaranteed to be logically 
>>> unchanged after the function call. For example:
>>>
>>> trait Foo {
>>>    fn foo(stable self);
>>> }
>>>
>>> impl Foo for int {
>>>    fn foo(&self) {} // OK
>>> }
>>>
>>> impl Foo for uint {
>>>    fn foo(self) {} // OK
>>> }
>>>
>>> impl Foo for Box<int> {
>>>    fn foo(stable self) {} // OK (implicitly clones self)
>>> }
>>>
>>>
>>> fn main() {
>>>    let x: Box<int> = box 42;
>>>    x.foo(); // `x` is implicitly cloned
>>>    x.foo(); // OK
>>> }
>>>
>>> _______________________________________________
>>> Rust-dev mailing list
>>> [email protected]
>>> https://mail.mozilla.org/listinfo/rust-dev
>>
>>
>>
>> --
>> http://octayn.net/
>



-- 
http://octayn.net/
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to