mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-23 22:22:22 -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 name = exercise_info.name.leak();
|
||||
let dir = exercise_info.dir.map(|dir| &*dir.leak());
|
||||
|
||||
let hint = exercise_info.hint.trim().to_owned();
|
||||
let hint = exercise_info.hint.leak().trim_ascii();
|
||||
|
||||
Exercise {
|
||||
dir,
|
||||
|
@ -397,7 +396,7 @@ impl AppState {
|
|||
clear_terminal(writer)?;
|
||||
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() {
|
||||
writer.write_all(final_message.as_bytes())?;
|
||||
writer.write_all(b"\n")?;
|
||||
|
@ -445,7 +444,7 @@ mod tests {
|
|||
path: "exercises/0.rs",
|
||||
test: false,
|
||||
strict_clippy: false,
|
||||
hint: String::new(),
|
||||
hint: "",
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ pub struct Exercise {
|
|||
pub path: &'static str,
|
||||
pub test: bool,
|
||||
pub strict_clippy: bool,
|
||||
pub hint: String,
|
||||
pub hint: &'static str,
|
||||
pub done: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ fn main() -> Result<()> {
|
|||
let mut stdout = io::stdout().lock();
|
||||
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 ")?;
|
||||
stdout.flush()?;
|
||||
press_enter_prompt()?;
|
||||
|
|
Loading…
Reference in a new issue