| Crates.io | parenthesized_c |
| lib.rs | parenthesized_c |
| version | 0.1.0 |
| created_at | 2021-12-26 19:33:11.916075+00 |
| updated_at | 2021-12-26 19:33:11.916075+00 |
| description | A library that allows to parse `(C)` attribute tokens in `#[repr(C)]` |
| homepage | |
| repository | https://github.com/JohnScience/parenthesized_c |
| max_upload_size | |
| id | 503418 |
| size | 6,664 |
This is a simple library providing ParenthesizedC ZST that implements syn::parse::Parse and
thus, for example, can be used with syn::parse2() for the purpose of parsing (C) attribute tokens as in #[repr(C)] outer attribute.
extern crate syn;
extern crate outer_attribute;
extern crate parenthesized_c;
use parenthesized_c::ParenthesizedC;
use outer_attribute::different_layout::OuterAttribute;
fn main() -> syn::Result<()> {
let repr_c = syn::parse_str::<OuterAttribute>("#[repr(C)]")?;
let repr_transpartent = syn::parse_str::<OuterAttribute>("#[repr(transparent)]")?;
assert!(matches!(syn::parse2::<ParenthesizedC>(repr_c.tokens), Ok(_)));
assert!(matches!(syn::parse2::<ParenthesizedC>(repr_transpartent.tokens), Err(_)));
Ok(())
}