khonsulabs / bonsaidb

A developer-friendly document database that grows with you, written in Rust
https://bonsaidb.io/
Apache License 2.0
1.03k stars 37 forks source link

`Key` derive doesn't support lifetimes #283

Closed ecton closed 1 year ago

ecton commented 1 year ago

The following should be able to work:

#[derive(Key, Debug, Clone)]
struct Foo<'k> {
    string: Cow<'k, str>,
}

But the macro doesn't do whatever is needed to ensure 'k is extended for 'key in the Key implementation:

cannot infer an appropriate lifetime for lifetime parameter `'k` due to conflicting requirements
expected `bonsaidb::bonsaidb_core::key::KeyEncoding<'key>`
   found `bonsaidb::bonsaidb_core::key::KeyEncoding<'_>`
ecton commented 1 year ago

cc @ModProg -- I can make this work, but I wanted to at least let you see the macro-related work in case you wanted to grab it.