Re: [rust-dev] Question about lifetimes in type parameters

2013-06-01 Thread Niko Matsakis
Ah, one thouht, you may want to be more careful with the def'n of IterBytes on MapKey to be sure that the hashcodes are the same. Niko On Sat, Jun 01, 2013 at 06:46:00AM -0400, Niko Matsakis wrote: > OK, I finally got a chance to take a look. Indeed, this is not a bug, > I just misunderstood wh

Re: [rust-dev] Question about lifetimes in type parameters

2013-06-01 Thread Niko Matsakis
OK, I finally got a chance to take a look. Indeed, this is not a bug, I just misunderstood what was going on. The problem is that the key is `&'b [u8]` but you can't supply precisely that type, because the key you are using to do th elookup has a shorter lifetime. This is true and the type checker

Re: [rust-dev] Question about lifetimes in type parameters

2013-05-31 Thread Niko Matsakis
Hi, sorry I haven't had a chance to look at this yet, I'll try to get to it today! Niko On Thu, May 30, 2013 at 09:00:32AM -0500, Tommy M. McGuire wrote: > On 05/30/2013 05:09 AM, Niko Matsakis wrote: > > On Wed, May 29, 2013 at 04:55:31PM -0500, Tommy M. McGuire wrote: > >> The problem is tha

Re: [rust-dev] Question about lifetimes in type parameters

2013-05-30 Thread Tommy M. McGuire
On 05/30/2013 05:09 AM, Niko Matsakis wrote: > On Wed, May 29, 2013 at 04:55:31PM -0500, Tommy M. McGuire wrote: >> The problem is that I want to use a completely unrelated vector as the >> argument to find() instead of an alias for part of the buffer or a pair >> of indices into the buffer. >> >>

Re: [rust-dev] Question about lifetimes in type parameters

2013-05-30 Thread Niko Matsakis
On Wed, May 29, 2013 at 04:55:31PM -0500, Tommy M. McGuire wrote: > The problem is that I want to use a completely unrelated vector as the > argument to find() instead of an alias for part of the buffer or a pair > of indices into the buffer. > > Currently, with my quick change to incoming, the co

Re: [rust-dev] Question about lifetimes in type parameters

2013-05-29 Thread Tommy M. McGuire
On 05/29/2013 04:55 AM, Niko Matsakis wrote: > On Tue, May 28, 2013 at 01:48:55PM -0500, Tommy M. McGuire wrote: >> The problem I am running into is that the type of the LinearMap's find() >> method (Yes, this is 0.6.) is: >> >> fn find(&self, k: &&'b [u8]) -> Option<&'self &'b [u8]> >> >> In other

Re: [rust-dev] Question about lifetimes in type parameters

2013-05-29 Thread Niko Matsakis
On Tue, May 28, 2013 at 01:48:55PM -0500, Tommy M. McGuire wrote: > The problem I am running into is that the type of the LinearMap's find() > method (Yes, this is 0.6.) is: > > fn find(&self, k: &&'b [u8]) -> Option<&'self &'b [u8]> > > In other words, the key argument is a borrowed pointer to a

[rust-dev] Question about lifetimes in type parameters

2013-05-28 Thread Tommy M. McGuire
I have a largeish buffer containing bytes that I would like to avoid copying. The first thing I have to do with this buffer is parse it into a hashmap structure. To that end, I have the following function: fn line_map<'b>(buffer : &'b [u8]) -> ~LinearMap<&'b [u8],&'b [u8]> {...} The problem I am