Re: [rust-dev] Help needed writing idiomatic rust to pass sequences of strings around

2014-03-25 Thread Phil Dawes
Thanks Huon, that really cleared things up for me. Dum question: What's the reason for str being a special fat pointer as a language feature rather than just a vanilla struct? E.g. struct StrSliceT {start: T, length: uint} (I suppose this question also applies to [T]) On Mon, Mar 24, 2014 at

Re: [rust-dev] Help needed writing idiomatic rust to pass sequences of strings around

2014-03-25 Thread Phil Dawes
Oops, I sent that before I finished editing it. I meant struct StrSlice {start: u8, length: uint} On Tue, Mar 25, 2014 at 4:33 PM, Phil Dawes rustp...@phildawes.net wrote: Thanks Huon, that really cleared things up for me. Dum question: What's the reason for str being a special fat pointer

Re: [rust-dev] Help needed writing idiomatic rust to pass sequences of strings around

2014-03-24 Thread Phil Dawes
To complete my understanding: is there a reason a 'sufficiently smart compiler' in the future couldn't do this conversion implicitly? I.e. if a function takes a borrowed reference to a container of pointers, could the compiler ignore what type of pointers they are (because they won't be going out

Re: [rust-dev] Help needed writing idiomatic rust to pass sequences of strings around

2014-03-24 Thread Huon Wilson
It would be necessary (but not sufficient*) for them to have the same in-memory representation, and currently ~str and str don't. ~str is `*{ length: uint, capacity: uint, data... }`, a pointer to a vector with the length and capacity stored inline, i.e. one word; str is just `{ data: *u8,

Re: [rust-dev] Help needed writing idiomatic rust to pass sequences of strings around

2014-03-23 Thread Patrick Walton
On 3/23/14 12:11 AM, Phil Dawes wrote: On Sun, Mar 23, 2014 at 2:04 AM, Patrick Walton pcwal...@mozilla.com mailto:pcwal...@mozilla.com wrote: Why not change the signature of `search_crate` to take `~str`? Patrick Hi Patrick, The main reason I haven't done this is that it is already

Re: [rust-dev] Help needed writing idiomatic rust to pass sequences of strings around

2014-03-23 Thread Huon Wilson
On 23/03/14 18:14, Patrick Walton wrote: On 3/23/14 12:11 AM, Phil Dawes wrote: On Sun, Mar 23, 2014 at 2:04 AM, Patrick Walton pcwal...@mozilla.com mailto:pcwal...@mozilla.com wrote: Why not change the signature of `search_crate` to take `~str`? Patrick Hi Patrick, The main reason

Re: [rust-dev] Help needed writing idiomatic rust to pass sequences of strings around

2014-03-23 Thread Phil Dawes
Great, thanks Patrick + Huon On Sun, Mar 23, 2014 at 7:47 AM, Huon Wilson dbau...@gmail.com wrote: On 23/03/14 18:14, Patrick Walton wrote: On 3/23/14 12:11 AM, Phil Dawes wrote: On Sun, Mar 23, 2014 at 2:04 AM, Patrick Walton pcwal...@mozilla.com mailto:pcwal...@mozilla.com wrote:

[rust-dev] Help needed writing idiomatic rust to pass sequences of strings around

2014-03-22 Thread Phil Dawes
Hello!, I'm learning rust and finding myself fighting the language a little and so I could do with a bit of help. In my code completion project I have a function which parses 'use' view items (using libsyntax) and currently returns a vector of vectors of strings representing fully qualified