pub fn classify_unit(
unit: &SemanticUnit,
path: &Path,
config: &Config,
) -> CodeTypeExpand description
Classifies a semantic unit as production or test code
§Arguments
unit- The semantic unit to classifypath- Path to the file containing the unitconfig- Configuration
§Returns
Classification of the code
§Examples
use std::path::Path;
use rust_diff_analyzer::{
classifier::classify_unit,
config::Config,
types::{LineSpan, SemanticUnit, SemanticUnitKind, Visibility},
};
let unit = SemanticUnit::new(
SemanticUnitKind::Function,
"test_something".to_string(),
Visibility::Private,
LineSpan::new(1, 10),
vec!["test".to_string()],
);
let config = Config::default();
let classification = classify_unit(&unit, Path::new("src/lib.rs"), &config);
assert!(classification == rust_diff_analyzer::types::CodeType::Test);