onlytypes 0.1.0

A library for creating types that can only be created by a certain function
Documentation
use crate::*;

// pub fn return_error(error: &str) -> crate::TokenStream {
//     format!(r#"compile_error!("{}")"#, error).parse().expect("Failed to parse macro")
// }

pub struct SomeFunction {
    pub attrs: Vec<Attribute>,
    pub vis: Visibility,
    pub defaultness: Option<Token![default]>,
    pub sig: Signature,
    pub block: Block,
}

impl From<ItemFn> for SomeFunction {
    fn from(f: ItemFn) -> Self {
        Self {
            attrs: f.attrs,
            vis: f.vis,
            defaultness: None,
            sig: f.sig,
            block: *f.block,
        }
    }
}

impl From<ImplItemFn> for SomeFunction {
    fn from(f: ImplItemFn) -> Self {
        Self {
            attrs: f.attrs,
            vis: f.vis,
            defaultness: f.defaultness,
            sig: f.sig,
            block: f.block,
        }
    }
}

impl From<&ItemFn> for SomeFunction {
    fn from(f: &ItemFn) -> Self {
        Self::from(f.clone())
    }
}

impl From<&ImplItemFn> for SomeFunction {
    fn from(f: &ImplItemFn) -> Self {
        Self::from(f.clone())
    }
}