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
53
54
55
56
57
58
59
60
61
62
63
64
//! # const_struct
//!
//! This crate provides a way to create a struct with const generics and const values.
//! ```
//! use const_struct::{primitive::F32Ty, F32};
//! pub fn tester<A: F32Ty>() {
//! println!("a: {:?}", A::__DATA);
//! }
//! fn main() {
//! tester::<F32!(0.5)>();
//! }
//! ```
//!
//! This crate is no_std.
//! used unsafe code:
//! * `core::mem::zeroed`
//! * `core::mem::transmute`
//!
//! example code
//! ```ignore
//! use const_struct::{call_with_generics, const_struct, ConstStruct};
//! #[derive(ConstStruct, Debug)]
//! pub struct TestGenerics<const T: usize> {
//! float: f32,
//! }
//! const COUNT: usize = 7;
//! #[const_struct]
//! const B: TestGenerics<{ COUNT }> = TestGenerics { float: 0.0 };
//! const fn constant<const T: usize, S: TestGenericsTy<T>>() -> f32 {
//! S::FLOAT
//! }
//!
//! const FLOAT: f32 = call_with_generics!(constant::<test_generics!(BTy)>());
//! ```
//!
//! If you see other complex example code,
//! you see https://github.com/oligamiq/const_struct/tree/main/crates/test_code
//!
//! See the Github README for more information.
pub use PrimitiveTraits;
pub use *;
pub use ConstDefault;