srcmetrics 0.1.0

Language-independent source code metrics (size, complexity, nesting, Halstead, duplication, dependencies, documentation) for C, C++, Go, Java, JavaScript, Python, Rust and TypeScript
Documentation
//! Rust mapping (tree-sitter-rust).

use super::Mapping;
use crate::ir::NodeKind::*;

pub static MAPPING: Mapping = Mapping {
    language: "rust",
    extensions: &["rs"],
    grammar: || tree_sitter_rust::LANGUAGE.into(),
    grammar_crate: ("tree-sitter-rust", "0.24.2"),
    kinds: &[
        ("block", Block),
        ("expression_statement", Statement),
        ("let_declaration", Declaration),
        ("if_expression", Branch),
        ("else_clause", Else),
        ("for_expression", Loop),
        ("while_expression", Loop),
        ("loop_expression", Loop),
        ("match_arm", Case),
        ("return_expression", Return),
        ("break_expression", Jump),
        ("continue_expression", Jump),
        ("call_expression", Call),
        ("macro_invocation", Call),
        ("assignment_expression", Assignment),
        ("compound_assignment_expr", Assignment),
        ("binary_expression", Binary),
        ("unary_expression", Unary),
        ("reference_expression", Unary),
        ("index_expression", Expression),
        ("field_expression", Expression),
        ("parenthesized_expression", Expression),
        ("identifier", Identifier),
        ("integer_literal", Literal),
        ("float_literal", Literal),
        ("string_literal", Literal),
        ("raw_string_literal", Literal),
        ("char_literal", Literal),
        ("boolean_literal", Literal),
        ("use_declaration", Import),
        ("extern_crate_declaration", Import),
        ("function_item", Function),
        ("closure_expression", Function),
    ],
    callee_fields: &["function", "macro"],
    logical_operators: &["&&", "||"],
    default_case_keyword: None,
    else_field: None,
    comments: &["line_comment", "block_comment"],
    literals: &[
        "integer_literal",
        "float_literal",
        "string_literal",
        "raw_string_literal",
        "char_literal",
        "boolean_literal",
    ],
    interpolations: &[],
    identifiers: &[
        "identifier",
        "field_identifier",
        "type_identifier",
        "shorthand_field_identifier",
    ],
    name_fields: &["name", "pattern"],
    decorators: &["attribute_item"],
    docstring: None,
    parameter_fields: &["parameters"],
    ignored_parameters: &[],
};