A normalizing representer for Exercism's Rust track.
A representer's job is to normalize some input code by stripping out and replacing any trivial details that introduce differences between students' submitted code. Comments, whitespace, and variable names, things that don't contribute to the overall logical flow and structure of the students' approach, are stripped out. In the case of variable names, these are replaced by a standard placeholder.
The ultimate purpose of the representer is to facilitate quicker response times from mentors by standardizing student implementations so that mentors can provide feedback on the approach the student took to solve the problem.
Given an example submission for the two-fer
exercise like the following:
fn twofer(name: &str) -> String {
match name {
"" => "One for you, one for me.".to_string(),
// use the `format!` macro to return a formatted String
_ => format!("One for {}, one for me.", name),
}
}
The representer will return:
fn PLACEHOLDER_1(PLACEHOLDER_2: &str) -> String {
match PLACEHOLDER_2 {
"" => "One for you, one for me.".to_string(),
_ => format!("One for {}, one for me.", PLACEHOLDER_2),
}
}
Currently the following statement/expression types are visited by the representer:
let
bindingsstruct
namesstruct
fieldsenum
namesenum
variantsfn
definitionsfn
callsconst
namesstatic
namesunion
namestype
aliasesmatch
expressionsmatch
armsmacro
argumentsfor
loopswhile
loopsloop
sif
expressionsimpl
blocksif let
bindingsmod
importsThe high-level steps the representer takes are as follows:
Download Details:
Author: exercism
Official Github: https://github.com/exercism/rust-representer
License: AGPL-3.0 license