enum_dispatch/
syn_utils.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! Contains common convenience methods for building `syn` syntactical constructs.

use syn::{punctuated::Punctuated, Expr, ExprPath, Ident, Path, PathArguments, PathSegment};

use std::iter::FromIterator;

/// Builds an expression from an identifier, i.e. just a named variable
pub fn plain_identifier_expr(ident: Ident) -> Expr {
    Expr::Path(ExprPath {
        attrs: vec![],
        qself: None,
        path: Path {
            leading_colon: None,
            segments: Punctuated::from_iter(vec![PathSegment {
                ident,
                arguments: PathArguments::None,
            }]),
        },
    })
}