1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! # EngCon
//!
//! EngCon (Engineering Contracts) is a set of macros and traits defining contracts often found in
//! engineering problems, e.g. the design of a distilation column.
//!
//! This crate only contains derive macros for use with the
//! [`engcon`](https://docs.rs/engcon)
//! crate. The macros provied by this crate are also available by
//! enabling the `derive` feature in aforementioned `engcon` crate.
use parse_macro_input;
use DeriveInput;
/// Makes a type validateable, means it implements the [engcon::Validator] trait.
///
/// Core idea is to get the domain contracts from experts, i.e. engineers or
/// other staff, in an easy readable approach for easy interdisciplinary discussions.
///
/// # Example - Distillation Column
///
/// ```
/// use engcon::*;
/// use engcon_macros::Validatable;
/// #[derive(Debug, Clone, Default, Copy, PartialEq, Validatable)]
/// pub struct DistillationColumn {
/// #[validate_value(x >= 3)]
/// pub trays: i32,
/// #[validate_value(x < trays, x >= 1)]
/// pub feed_place: i32,
/// #[validate_value(x > 0.0)]
/// pub reflux_ratio: f32,
/// //#[serde(rename = "d2f")]
/// #[validate_value(x > 0.0, x < 1.0)]
/// pub distiliate_to_feed_ratio: f32,
/// }
/// ```
///
/// # Generated Code
///
///