Re: [rust-dev] Passing arguments bu reference

2014-06-02 Thread Christophe Pedretti
Great Thanks to all, now i have a more precise idea. So, to summarize if the function takes a vector as argument, transforms it, and return it, with no need for the caller to use the argument fn my_func(src: Vecu8) - Vecu8 if the functons takes a vector argument and use it just for a temporary

[rust-dev] Passing arguments bu reference

2014-06-01 Thread Christophe Pedretti
Hello all, I've read this : http://words.steveklabnik.com/pointers-in-rust-a-guide I am coming from Java where everything is passed and returned by reference (except for primitive data types), no choice. I know that with C, you have to use pointers to avoid passing and returning by value. When

Re: [rust-dev] Passing arguments bu reference

2014-06-01 Thread Daniel Micay
On 01/06/14 04:34 AM, Christophe Pedretti wrote: Hello all, I've read this : http://words.steveklabnik.com/pointers-in-rust-a-guide I am coming from Java where everything is passed and returned by reference (except for primitive data types), no choice. I know that with C, you have to

Re: [rust-dev] Passing arguments bu reference

2014-06-01 Thread Vladimir Matveev
Aw, Gmail makes it so easy to press Reply instead of Reply to all. See below :) Hi, Christophe, Because `Vec` looks like this: struct VecT { len: uint, cap: uint, data: *mut T } its actual size is just three words, so you can freely pass it around regardless of number of

Re: [rust-dev] Passing arguments bu reference

2014-06-01 Thread Steve Klabnik
one of the recent changes with box is that it does placement new. So generally, this is bad: fn foo(x: int) - Boxint { box (x + 1) } let y = foo(5); Because it forces your caller to use a Box. Instead... fn foo(x: int) - int { x + 1 } Because then your caller can choose: let y =