Skip to main content

HasFk

Derive Macro HasFk 

Source
#[derive(HasFk)]
{
    // Attributes available to this derive:
    #[fk_field]
    #[has_fk]
}
Expand description

Implement the configured DBC HasFk trait for a named-field structure.

ยงExample

mod support {
    pub trait HasFk {
        fn fk(&self) -> i32;
    }
}

use support::HasFk as _;
use wowlab_engine_macros::HasFk;

#[derive(HasFk)]
#[fk_field = "parent_id"]
#[has_fk(crate = "crate::support")]
struct Row {
    parent_id: i32,
}

fn main() {
    assert_eq!(Row { parent_id: 7 }.fk(), 7);
}