If the values are cached, and the structure implementing the cache has the same lifetime (or longer? Unsure on that...) as the map then I'd expect it to work. For generated/retrieved, non-cached values I don't believe it would work. On 2013-09-25 7:54 PM, "Daniel Micay" <[email protected]> wrote:
> On Wed, Sep 25, 2013 at 10:36 PM, David Brown <[email protected]> wrote: > >> Let's say I'm implementing some type of map-like structure that I'd >> like to be able to implement the Map trait on. >> >> However, my map doesn't actually store the 'V' directly, but they are >> computed/retrieve/cached in some manner. >> >> Is this possible with the existing map trait? Given that: >> >> fn find<'a>(&'a self, key: &K) -> Option<&'a V>; >> >> doesn't the V need to be a pointer to something with the same lifetime >> as self? >> >> Is there a way of dealing with this, or should I just implement my own >> similar find function, not implementing Map, and return an Option<V> >> instead? >> > > The Map trait represents a map storing the values, so it can't be used for > that use case. > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
