pub trait KeyedMut: Keyed {
    fn set_key(&mut self, key: Self::Key);
}
Expand description

Trait to set 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 crate::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()};
u.set_key(55.into());

/// assert_eq!(u.id , 55);

Here the number 5 is converted into the key type of User. Then this key is set.

Required Methods

Set the key of the implementing struct.

Implementors