mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-11-08 09:09:17 +01:00
Some renamings
This commit is contained in:
parent
99c9ab467b
commit
93f8d1610d
@ -41,11 +41,11 @@ pub enum Mode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct ExerciseList {
|
pub struct InfoFile {
|
||||||
pub exercises: Vec<Exercise>,
|
pub exercises: Vec<Exercise>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExerciseList {
|
impl InfoFile {
|
||||||
pub fn parse() -> Result<Self> {
|
pub fn parse() -> Result<Self> {
|
||||||
// Read a local `info.toml` if it exists.
|
// Read a local `info.toml` if it exists.
|
||||||
// Mainly to let the tests work for now.
|
// Mainly to let the tests work for now.
|
||||||
|
@ -56,7 +56,7 @@ fn create_vscode_dir() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_rustlings(exercises: &[Exercise]) -> Result<()> {
|
pub fn init(exercises: &[Exercise]) -> Result<()> {
|
||||||
if Path::new("exercises").is_dir() && Path::new("Cargo.toml").is_file() {
|
if Path::new("exercises").is_dir() && Path::new("Cargo.toml").is_file() {
|
||||||
bail!(
|
bail!(
|
||||||
"A directory with the name `exercises` and a file with the name `Cargo.toml` already exist
|
"A directory with the name `exercises` and a file with the name `Cargo.toml` already exist
|
||||||
|
@ -16,7 +16,7 @@ mod verify;
|
|||||||
mod watch;
|
mod watch;
|
||||||
|
|
||||||
use crate::consts::WELCOME;
|
use crate::consts::WELCOME;
|
||||||
use crate::exercise::{Exercise, ExerciseList};
|
use crate::exercise::{Exercise, InfoFile};
|
||||||
use crate::run::run;
|
use crate::run::run;
|
||||||
use crate::verify::verify;
|
use crate::verify::verify;
|
||||||
|
|
||||||
@ -84,10 +84,10 @@ Did you already install Rust?
|
|||||||
Try running `cargo --version` to diagnose the problem.",
|
Try running `cargo --version` to diagnose the problem.",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let exercises = ExerciseList::parse()?.exercises;
|
let exercises = InfoFile::parse()?.exercises;
|
||||||
|
|
||||||
if matches!(args.command, Some(Subcommands::Init)) {
|
if matches!(args.command, Some(Subcommands::Init)) {
|
||||||
init::init_rustlings(&exercises).context("Initialization failed")?;
|
init::init(&exercises).context("Initialization failed")?;
|
||||||
println!(
|
println!(
|
||||||
"\nDone initialization!\n
|
"\nDone initialization!\n
|
||||||
Run `cd rustlings` to go into the generated directory.
|
Run `cd rustlings` to go into the generated directory.
|
||||||
|
Loading…
Reference in New Issue
Block a user