[][src]Function rust_code_analysis::metrics

pub fn metrics<'a, T: TSParserTrait>(
    parser: &'a T,
    path: &'a PathBuf
) -> Option<FuncSpace<'a>>

Returns function space data of the code in a file.

Examples

use std::path::PathBuf;

use rust_code_analysis::{CppParser, metrics, TSParserTrait};

let source_code = "int a = 42;";

// The path to a dummy file used to contain the source code
let path = PathBuf::from("foo.c");
let source_as_vec = source_code.as_bytes().to_vec();

// The parser of the code, in this case a CPP parser
let parser = CppParser::new(source_as_vec.clone(), &path, None);

// Gets the function space data of the code contained in foo.c
metrics(&parser, &path).unwrap();