Crate syn_mid

source ·
Expand description

Providing the features between “full” and “derive” of syn.

This crate provides the following two unique data structures.

  • syn_mid::ItemFn – A function whose body is not parsed.

    fn process(n: usize) -> Result<()> { ... }
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^     ^
    
  • syn_mid::Block – A block whose body is not parsed.

    { ... }
    ^     ^
    

Other data structures are the same as data structures of syn. These are defined in this crate because they cannot be used in syn without “full” feature.

Usage

Add this to your Cargo.toml:

[dependencies]
syn-mid = "0.5"

Compiler support: requires rustc 1.56+

Examples

Optional features

  • clone-impls — Clone impls for all syntax tree types.

Re-exports

Structs

  • A braced block containing Rust statements.
  • A single field in a struct pattern.
  • A free-standing function: fn process(n: usize) -> Result<()> { ... }.
  • A pattern that binds a new variable: ref mut binding @ SUBPATTERN.
  • A reference pattern: &mut var.
  • The dots in a tuple pattern: [0, 1, ..].
  • A struct or struct variant pattern: Variant { x, y, .. }.
  • A tuple pattern: (a, b).
  • A tuple struct or tuple variant pattern: Variant(x, y, .., z).
  • A type ascription pattern: foo: f64.
  • A pattern that matches any value: _.
  • The self argument of an associated method, whether taken by value or by reference.
  • A function signature in a trait or implementation: unsafe fn initialize(&self).
  • The variadic argument of a foreign function.

Enums

  • An argument in a function signature: the n: usize in fn f(n: usize).
  • A pattern in a local binding, function signature, match expression, or various other places.