parenthesized_c

Crates.ioparenthesized_c
lib.rsparenthesized_c
version0.1.0
sourcesrc
created_at2021-12-26 19:33:11.916075
updated_at2021-12-26 19:33:11.916075
descriptionA library that allows to parse `(C)` attribute tokens in `#[repr(C)]`
homepage
repositoryhttps://github.com/JohnScience/parenthesized_c
max_upload_size
id503418
size6,664
Dmitrii - Demenev (JohnScience)

documentation

https://docs.rs/parenthesized_c

README

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.

Example:

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(())
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 6

cargo fmt