mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-24 06:22:23 -05:00
Use trim_ascii
instead of trim
This commit is contained in:
parent
1468206052
commit
5016c7cf7c
4 changed files with 6 additions and 7 deletions
|
@ -107,8 +107,7 @@ impl AppState {
|
||||||
let path = exercise_info.path().leak();
|
let path = exercise_info.path().leak();
|
||||||
let name = exercise_info.name.leak();
|
let name = exercise_info.name.leak();
|
||||||
let dir = exercise_info.dir.map(|dir| &*dir.leak());
|
let dir = exercise_info.dir.map(|dir| &*dir.leak());
|
||||||
|
let hint = exercise_info.hint.leak().trim_ascii();
|
||||||
let hint = exercise_info.hint.trim().to_owned();
|
|
||||||
|
|
||||||
Exercise {
|
Exercise {
|
||||||
dir,
|
dir,
|
||||||
|
@ -397,7 +396,7 @@ impl AppState {
|
||||||
clear_terminal(writer)?;
|
clear_terminal(writer)?;
|
||||||
writer.write_all(FENISH_LINE.as_bytes())?;
|
writer.write_all(FENISH_LINE.as_bytes())?;
|
||||||
|
|
||||||
let final_message = self.final_message.trim();
|
let final_message = self.final_message.trim_ascii();
|
||||||
if !final_message.is_empty() {
|
if !final_message.is_empty() {
|
||||||
writer.write_all(final_message.as_bytes())?;
|
writer.write_all(final_message.as_bytes())?;
|
||||||
writer.write_all(b"\n")?;
|
writer.write_all(b"\n")?;
|
||||||
|
@ -445,7 +444,7 @@ mod tests {
|
||||||
path: "exercises/0.rs",
|
path: "exercises/0.rs",
|
||||||
test: false,
|
test: false,
|
||||||
strict_clippy: false,
|
strict_clippy: false,
|
||||||
hint: String::new(),
|
hint: "",
|
||||||
done: false,
|
done: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<hashbrown::HashSet<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if exercise_info.hint.trim().is_empty() {
|
if exercise_info.hint.trim_ascii().is_empty() {
|
||||||
bail!("The exercise `{name}` has an empty hint. Please provide a hint or at least tell the user why a hint isn't needed for this exercise");
|
bail!("The exercise `{name}` has an empty hint. Please provide a hint or at least tell the user why a hint isn't needed for this exercise");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub struct Exercise {
|
||||||
pub path: &'static str,
|
pub path: &'static str,
|
||||||
pub test: bool,
|
pub test: bool,
|
||||||
pub strict_clippy: bool,
|
pub strict_clippy: bool,
|
||||||
pub hint: String,
|
pub hint: &'static str,
|
||||||
pub done: bool,
|
pub done: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ fn main() -> Result<()> {
|
||||||
let mut stdout = io::stdout().lock();
|
let mut stdout = io::stdout().lock();
|
||||||
clear_terminal(&mut stdout)?;
|
clear_terminal(&mut stdout)?;
|
||||||
|
|
||||||
let welcome_message = welcome_message.trim();
|
let welcome_message = welcome_message.trim_ascii();
|
||||||
write!(stdout, "{welcome_message}\n\nPress ENTER to continue ")?;
|
write!(stdout, "{welcome_message}\n\nPress ENTER to continue ")?;
|
||||||
stdout.flush()?;
|
stdout.flush()?;
|
||||||
press_enter_prompt()?;
|
press_enter_prompt()?;
|
||||||
|
|
Loading…
Reference in a new issue