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.
>>
>> Currently, with my quick change to incoming, the code
>>
>> let kkey : &[u8] = key; // key : ~[u8]
>> match dictionary.find(&kkey) {
>>
>> produces:
>>
>> 55:38 error: borrowed value does not live long enough
>> let kkey : &[u8] = key;
>> ^~~
>> 67:1 note: borrowed pointer must be valid for the lifetime
>> &br_named({repr: 83, ctxt: 0}) as defined on the block at 48:0...
>> ...
>> 65:5 note: ...but borrowed value is only valid for the block at 50:46
>>
>> The lifetime '&br_named(...)' stuff should be "'b", the lifetime
>> parameter of the function (the block at 48:0) that is associated with
>> the keys and values from the HashMap (was LinearMap) and the buffer.
>
> This seems like a bug (also, what a lousy error message! sorry.), I
> will further investigate.
Thanks! (The error message changed when I updated incoming, so it's
something recent.)
I'm not sure it is a bug, though. I may not be understanding lifetimes
well enough, but I think the interaction between that and generics is
problematic. In this case, there doesn't seem to be enough information
to tell the difference between find(), for which the lifetime argument
is not terribly useful, and insert(), where it would be.
--
Tommy M. McGuire
[email protected]
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev