1#![forbid(unsafe_code)]
2#![warn(missing_docs)]
3#![warn(clippy::pedantic)]
4
5mod attribute;
8mod common;
9mod derive;
10mod r#enum;
11mod generate;
12mod mode;
13mod r#struct;
14
15use crate::derive::derive;
16use crate::mode::Mode;
17use proc_macro::TokenStream;
18use syn::{parse_macro_input, DeriveInput};
19
20#[proc_macro_derive(ToBorrowed, attributes(ownable))]
24pub fn to_borrowed(tokens: TokenStream) -> TokenStream {
25 let input = parse_macro_input!(tokens as DeriveInput);
26 derive(&input, Mode::ToBorrowed).into()
27}
28
29#[proc_macro_derive(ToOwned, attributes(ownable))]
31pub fn to_owned(tokens: TokenStream) -> TokenStream {
32 let input = parse_macro_input!(tokens as DeriveInput);
33 derive(&input, Mode::ToOwned).into()
34}
35
36#[proc_macro_derive(IntoOwned, attributes(ownable))]
38pub fn into_owned(tokens: TokenStream) -> TokenStream {
39 let input = parse_macro_input!(tokens as DeriveInput);
40 derive(&input, Mode::IntoOwned).into()
41}