// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
use proc_macro::TokenStream;

mod namedtuple;
mod record;

#[proc_macro_attribute]
/// Make a struct into a record, which makes all of it's fields public
///
/// # Example
/// ```
/// #[moretypes::record]
/// struct Record {
///     field: u32,
/// }
///
/// let record = Record { field: 69 };
/// assert_eq!(record.field, 69, "Value is not nice: {}", record.field);
/// ```
pub fn record(_attr: TokenStream, item: TokenStream) -> TokenStream {
    record::record(_attr, item)
}

#[proc_macro_attribute]
/// Make a struct into a named tuple, which gives it these properties:
/// - A constructor (disable using `constructor = false`)
/// - Methods to convert to and from tuples (disable using `tuple_methods = false`)
/// All ordering is based on field declaration order, parameters are passed to the attribute
///
/// # Example
/// ```
/// #[moretypes::named_tuple]
/// #[derive(Debug)]
/// struct NamedTuple {
///     pub x: u32,
///     pub y: u32,
/// }
///
/// let named_tuple = NamedTuple::new(35,34);
/// assert_eq!(named_tuple.x + named_tuple.y, 69, "Named tuple is not nice: {:?}", named_tuple);
/// assert_eq!(named_tuple.as_tuple(), (35, 34));
/// ```
pub fn named_tuple(attr: TokenStream, item: TokenStream) -> TokenStream {
    namedtuple::named_tuple(attr, item)
}
