mshc-macro-shared 0.1.0

Shared macro source for 'mshc' and 'mshc-derive'
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#[macro_export]
macro_rules! req_field {
    (named $data:ident, $field:literal) => {
        $data.named.iter().find(|f| {
            f.ident.as_ref().map_or(false, |i| i == $field)
        })  .map(|f| f.ident.as_ref().unwrap())
            .expect(&format!("No '{}' field found in struct layout", $field))
    };

    ($data:ident, $field:literal) => {
        $data.fields.iter().find(|f| {
            f.ident.as_ref().map_or(false, |i| i == $field)
        })  .map(|f| f.ident.as_ref().unwrap())
            .expect(&format!("No '{}' field found in struct layout", $field))
    };
}