castflip_derive/lib.rs
1#![doc = include_str!("front_page.md")]
2
3
4use proc_macro::TokenStream;
5
6
7mod cast;
8mod flip;
9mod nop_flip;
10
11
12///
13/// Derive macro generating an impl of trait [`Cast`] for a `struct`
14/// type or a `union` type.
15///
16/// It must be applied together with attribute `#[`[`repr(C)`]`]`.
17///
18/// For detailed information, see the document of trait [`Cast`].
19///
20/// [`Cast`]: https://docs.rs/castflip/0.1/castflip/trait.Cast.html
21/// [`repr(C)`]: https://doc.rust-lang.org/reference/type-layout.html#the-c-representation
22///
23#[proc_macro_derive(Cast)]
24pub fn cast_derive(input: TokenStream) -> TokenStream {
25 cast::proc_tokens(input)
26}
27
28
29///
30/// Derive macro generating an impl of trait [`Flip`] for a `struct`
31/// type.
32///
33/// For detailed information, see the document of trait [`Flip`].
34///
35/// [`Flip`]: https://docs.rs/castflip/0.1/castflip/trait.Flip.html
36///
37#[proc_macro_derive(Flip)]
38pub fn flip_derive(input: TokenStream) -> TokenStream {
39 flip::proc_tokens(input)
40}
41
42
43///
44/// Derive macro generating an impl of both trait [`Flip`] whose
45/// methods do nothing and trait [`NopFlip`] for a `struct` type or a
46/// `union` type.
47///
48/// For detailed information, see the document of trait [`NopFlip`].
49///
50/// [`NopFlip`]: https://docs.rs/castflip/0.1/castflip/trait.NopFlip.html
51///
52#[proc_macro_derive(NopFlip)]
53pub fn nop_flip_derive(input: TokenStream) -> TokenStream {
54 nop_flip::proc_tokens(input)
55}