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 borrowed
> pointer to a vector with the same lifetime as the buffer. That argument
> is kind of difficult to provide.

First, I'm sure you've heard this before, but you'll probably be
happier if you bite the bullet and upgrade to incoming. There are a
lot of bugs fixed around the treatment of lifetimes, and more to come.

That said, why is a `&&[u8]` so difficult to provide? You can do
something like this:

    let my_slice: &[u8] = my_vec.slice(from, to);
    match map.find(&my_slice) { ... }

Or even:

    match map.find(&my_vec.slice(from, to)) { ... }

> What am I doing wrong? Is there a better way?

I think you are doing it right.  You may find it easier to just put
indices into the map rather than slices, but slices should work too.


Niko
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to