Crates.io | outer_attribute |
lib.rs | outer_attribute |
version | 0.1.1 |
source | src |
created_at | 2021-12-26 18:34:46.562143 |
updated_at | 2021-12-26 18:42:05.771394 |
description | A library providiving `OuterAttribute` that implements `syn::parse::Parse` trait. |
homepage | |
repository | https://github.com/JohnScience/outer_attribute |
max_upload_size | |
id | 503387 |
size | 8,965 |
OuterAttribute
that implements syn::parse::Parse
trait.At the time of writing, syn
crate doesn't offer a way to parse outer attributes (for example,
#[repr(C)]
) without declaring a struct and reinventing a wheel by implementing syn::parse::Parse
trait. Unlike syn::Attribute
,
depending on the enabled feature same_layout
or different_layout
the chosen
different_layout::OuterAttribute
or same_layout::OuterAttribute
, respectively, will have
syn::parse::Parse
available.
extern crate syn;
extern crate outer_attribute;
use outer_attribute::different_layout::OuterAttribute;
fn main() {
assert!(matches!(syn::parse_str::<OuterAttribute>("#[repr(C)]"), Ok(_)));
assert!(matches!(syn::parse_str::<OuterAttribute>("Not an outer attribute"), Err(_)));
}
The default feature is different_layout
and opting for same_layout
instead can be considered when
there is some functionality that is available on syn::Attribute
but not on either OuterAttribute
.