Expand description
Trait to read the key of a struct.
Implemented automatically for every Toql derived struct.
The trait can be used by library users.
Example
Basic usage (assume a Toql derived User struct):
ⓘ
use toql_core::keyed::Keyed;
use toql_derive::Toql;
#[derive(Toql)]
struct User{
#[toql(key)]
id: u64,
name: String
}
let u = User {id: 5, name: "Sue".to_string()};
let k = u.key();
assert_eq!(k.id , 5);
For collections there is map_key. It makes use of this trait.