onlytypes 0.1.0

A library for creating types that can only be created by a certain function
Documentation
#![doc = include_str!("./README.md")]

#![warn(missing_docs, unused, clippy::all)]

pub(crate) use proc_macro::TokenStream;
pub(crate) use quote::quote;
pub(crate) use syn::*;

pub(crate) const FEATURE_NAME: &str = "only-types";

pub(crate) const BASE_IGNORE: &str = r#"
#[cfg(not(feature = "only-types"))]
#[cfg_attr(feature = "only-types", doc = "This will be ignored by onlytypes.")]
"#;

mod stubbing;
mod utils;

#[doc = include_str!("./doc/IGNORE.md")]
#[proc_macro_attribute]
pub fn ignore(_: TokenStream, input: TokenStream) -> TokenStream {
    format!("{BASE_IGNORE}{}", input.to_string()).parse().unwrap()
}

#[doc = include_str!("./doc/STUB.md")]
#[proc_macro_attribute]
pub fn stub(_: TokenStream, input: TokenStream) -> TokenStream {
    if let Ok(f) = syn::parse::<ItemFn>(input.clone()) {
        return stubbing::stub_function(f);
    }
    if let Ok(f) = syn::parse::<ImplItemFn>(input.clone()) {
        return stubbing::stub_function(f);
    }
    panic!("Unable to stub that thing!");
    // if let Ok(i) = syn::parse::<ItemImpl>(input.clone()) {
    //     return stubbing::stub_impl(i);
    // }
    //input
}