[][src]Function rust_code_analysis::metrics

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

Returns all function spaces data of a code. This function needs a parser to be created a priori in order to work.

Examples

use std::path::PathBuf;

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

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, &path, None);

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