bounded_integer/examples.rs
1//! Examples of bounded integers generated by the [`bounded_integer!`] macro.
2//!
3//! This module is not present when using the crate.
4
5use crate::bounded_integer;
6
7bounded_integer! {
8 /// A bounded struct, implemented as a protected newtype.
9 ///
10 /// This was generated from:
11 /// ```
12 #[cfg_attr(feature = "step_trait", doc = "# #![feature(step_trait)]")]
13 /// # use bounded_integer::bounded_integer;
14 /// bounded_integer! {
15 /// pub struct BoundedStruct(-8, 7);
16 /// }
17 /// ```
18 pub struct BoundedStruct(-8, 7);
19}
20
21bounded_integer! {
22 /// A bounded enum.
23 ///
24 /// This was generated from:
25 /// ```
26 #[cfg_attr(feature = "step_trait", doc = "# #![feature(step_trait)]")]
27 /// # use bounded_integer::bounded_integer;
28 /// bounded_integer! {
29 /// pub enum BoundedEnum(-8, 7);
30 /// }
31 /// ```
32 pub enum BoundedEnum(-8, 7);
33}
34
35bounded_integer! {
36 /// A bounded enum with named variants.
37 ///
38 /// ```
39 #[cfg_attr(feature = "step_trait", doc = "# #![feature(step_trait)]")]
40 /// # use bounded_integer::bounded_integer;
41 /// bounded_integer! {
42 /// pub enum BoundedEnumNamed {
43 /// Zero,
44 /// One,
45 /// Two,
46 /// }
47 /// }
48 /// ```
49 pub enum BoundedEnumNamed {
50 Zero,
51 One,
52 Two,
53 }
54}