# solution is a helper to generate solution of exercise
## Quick start
```sh
cargo add solution
```
Add a solution feature in your crate.
```toml
[package]
name = "exo01"
[features]
solution = []
[dependencies]
solution = { version = "0.1.0" }
```
And use `solution!()` and/or `solution_type` macro, e.g.:
```rust
use solution::{solution,solution_type};
/// this struct should be removed
struct WhichType;
fn variable_strip_prefix(string: solution_type!(&str)) -> Option<solution_type!(WhichType => &str)> {
solution!({
string.strip_prefix("$")
})
}
fn main() {
for arg in std::env::args().skip(1) {
solution!(hint = "remove the optionnal '$' at start and display environment variable", {
let name = variable_strip_prefix(&arg).unwrap_or(&arg);
println!("{name} = {}", std::env::var(name).expect("404 variable not found"));
})
}
}
```
Now you can build student version with `cargo build` (but depends which you have write in `solution_type!()` it can be unable to build) and teacher version with `cargo build -F solution`.
## Generate student version
```sh
cargo install solution_cli
solution --source <teacher_directory> generate <student_directory>
```
The last command generate new rust file in `<student_directory>` :
```rust,ignore("student version can't be builded")
use solution::{solution,solution_type};
/// this struct should be removed
struct WhichType;
fn variable_strip_prefix(string: /* TODO: */ _) -> Option</* TODO: */ WhichType> {
todo!()
}
fn main() {
for arg in std::env::args().skip(1) {
todo!("remove the optionnal '$' at start and display environment variable")
}
}
```