mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-05-15 17:58:44 +00:00
Don't manually inline
This commit is contained in:
parent
c466d01da9
commit
95b6160b54
@ -180,37 +180,30 @@ impl AppState {
|
|||||||
Ok((slf, state_file_status))
|
Ok((slf, state_file_status))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn current_exercise_ind(&self) -> usize {
|
pub fn current_exercise_ind(&self) -> usize {
|
||||||
self.current_exercise_ind
|
self.current_exercise_ind
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn exercises(&self) -> &[Exercise] {
|
pub fn exercises(&self) -> &[Exercise] {
|
||||||
&self.exercises
|
&self.exercises
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn n_done(&self) -> u32 {
|
pub fn n_done(&self) -> u32 {
|
||||||
self.n_done
|
self.n_done
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn n_pending(&self) -> u32 {
|
pub fn n_pending(&self) -> u32 {
|
||||||
self.exercises.len() as u32 - self.n_done
|
self.exercises.len() as u32 - self.n_done
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn current_exercise(&self) -> &Exercise {
|
pub fn current_exercise(&self) -> &Exercise {
|
||||||
&self.exercises[self.current_exercise_ind]
|
&self.exercises[self.current_exercise_ind]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn cmd_runner(&self) -> &CmdRunner {
|
pub fn cmd_runner(&self) -> &CmdRunner {
|
||||||
&self.cmd_runner
|
&self.cmd_runner
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn emit_file_links(&self) -> bool {
|
pub fn emit_file_links(&self) -> bool {
|
||||||
self.emit_file_links
|
self.emit_file_links
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,7 +126,6 @@ pub struct CargoSubcommand<'out> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CargoSubcommand<'_> {
|
impl CargoSubcommand<'_> {
|
||||||
#[inline]
|
|
||||||
pub fn args<'arg, I>(&mut self, args: I) -> &mut Self
|
pub fn args<'arg, I>(&mut self, args: I) -> &mut Self
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = &'arg str>,
|
I: IntoIterator<Item = &'arg str>,
|
||||||
@ -136,7 +135,6 @@ impl CargoSubcommand<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The boolean in the returned `Result` is true if the command's exit status is success.
|
/// The boolean in the returned `Result` is true if the command's exit status is success.
|
||||||
#[inline]
|
|
||||||
pub fn run(self, description: &str) -> Result<bool> {
|
pub fn run(self, description: &str) -> Result<bool> {
|
||||||
run_cmd(self.cmd, description, self.output)
|
run_cmd(self.cmd, description, self.output)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -158,7 +158,6 @@ pub trait RunnableExercise {
|
|||||||
|
|
||||||
/// Compile, check and run the exercise.
|
/// Compile, check and run the exercise.
|
||||||
/// The output is written to the `output` buffer after clearing it.
|
/// The output is written to the `output` buffer after clearing it.
|
||||||
#[inline]
|
|
||||||
fn run_exercise(&self, output: Option<&mut Vec<u8>>, cmd_runner: &CmdRunner) -> Result<bool> {
|
fn run_exercise(&self, output: Option<&mut Vec<u8>>, cmd_runner: &CmdRunner) -> Result<bool> {
|
||||||
self.run::<false>(self.name(), output, cmd_runner)
|
self.run::<false>(self.name(), output, cmd_runner)
|
||||||
}
|
}
|
||||||
@ -201,22 +200,18 @@ pub trait RunnableExercise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RunnableExercise for Exercise {
|
impl RunnableExercise for Exercise {
|
||||||
#[inline]
|
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
self.name
|
self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn dir(&self) -> Option<&str> {
|
fn dir(&self) -> Option<&str> {
|
||||||
self.dir
|
self.dir
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn strict_clippy(&self) -> bool {
|
fn strict_clippy(&self) -> bool {
|
||||||
self.strict_clippy
|
self.strict_clippy
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn test(&self) -> bool {
|
fn test(&self) -> bool {
|
||||||
self.test
|
self.test
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ pub struct ExerciseInfo {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub skip_check_unsolved: bool,
|
pub skip_check_unsolved: bool,
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
const fn default_true() -> bool {
|
const fn default_true() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@ -55,22 +54,18 @@ impl ExerciseInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RunnableExercise for ExerciseInfo {
|
impl RunnableExercise for ExerciseInfo {
|
||||||
#[inline]
|
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
self.name
|
self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn dir(&self) -> Option<&str> {
|
fn dir(&self) -> Option<&str> {
|
||||||
self.dir
|
self.dir
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn strict_clippy(&self) -> bool {
|
fn strict_clippy(&self) -> bool {
|
||||||
self.strict_clippy
|
self.strict_clippy
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn test(&self) -> bool {
|
fn test(&self) -> bool {
|
||||||
self.test
|
self.test
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,6 @@ impl ScrollState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn offset(&self) -> usize {
|
pub fn offset(&self) -> usize {
|
||||||
self.offset
|
self.offset
|
||||||
}
|
}
|
||||||
@ -41,7 +40,6 @@ impl ScrollState {
|
|||||||
.min(global_max_offset);
|
.min(global_max_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn selected(&self) -> Option<usize> {
|
pub fn selected(&self) -> Option<usize> {
|
||||||
self.selected
|
self.selected
|
||||||
}
|
}
|
||||||
@ -86,12 +84,10 @@ impl ScrollState {
|
|||||||
self.set_selected(self.selected.map_or(0, |selected| selected.min(n_rows - 1)));
|
self.set_selected(self.selected.map_or(0, |selected| selected.min(n_rows - 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn update_scroll_padding(&mut self) {
|
fn update_scroll_padding(&mut self) {
|
||||||
self.scroll_padding = (self.max_n_rows_to_display / 4).min(self.max_scroll_padding);
|
self.scroll_padding = (self.max_n_rows_to_display / 4).min(self.max_scroll_padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn max_n_rows_to_display(&self) -> usize {
|
pub fn max_n_rows_to_display(&self) -> usize {
|
||||||
self.max_n_rows_to_display
|
self.max_n_rows_to_display
|
||||||
}
|
}
|
||||||
|
|||||||
@ -303,7 +303,6 @@ impl<'a> ListState<'a> {
|
|||||||
self.scroll_state.set_n_rows(n_rows);
|
self.scroll_state.set_n_rows(n_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn filter(&self) -> Filter {
|
pub fn filter(&self) -> Filter {
|
||||||
self.filter
|
self.filter
|
||||||
}
|
}
|
||||||
@ -313,22 +312,18 @@ impl<'a> ListState<'a> {
|
|||||||
self.update_rows();
|
self.update_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn select_next(&mut self) {
|
pub fn select_next(&mut self) {
|
||||||
self.scroll_state.select_next();
|
self.scroll_state.select_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn select_previous(&mut self) {
|
pub fn select_previous(&mut self) {
|
||||||
self.scroll_state.select_previous();
|
self.scroll_state.select_previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn select_first(&mut self) {
|
pub fn select_first(&mut self) {
|
||||||
self.scroll_state.select_first();
|
self.scroll_state.select_first();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn select_last(&mut self) {
|
pub fn select_last(&mut self) {
|
||||||
self.scroll_state.select_last();
|
self.scroll_state.select_last();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,6 @@ pub struct MaxLenWriter<'a, 'lock> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'lock> MaxLenWriter<'a, 'lock> {
|
impl<'a, 'lock> MaxLenWriter<'a, 'lock> {
|
||||||
#[inline]
|
|
||||||
pub fn new(stdout: &'a mut StdoutLock<'lock>, max_len: usize) -> Self {
|
pub fn new(stdout: &'a mut StdoutLock<'lock>, max_len: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
stdout,
|
stdout,
|
||||||
@ -28,7 +27,6 @@ impl<'a, 'lock> MaxLenWriter<'a, 'lock> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Additional is for emojis that take more space.
|
// Additional is for emojis that take more space.
|
||||||
#[inline]
|
|
||||||
pub fn add_to_len(&mut self, additional: usize) {
|
pub fn add_to_len(&mut self, additional: usize) {
|
||||||
self.len += additional;
|
self.len += additional;
|
||||||
}
|
}
|
||||||
@ -64,24 +62,20 @@ impl<'lock> CountedWrite<'lock> for MaxLenWriter<'_, 'lock> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn stdout(&mut self) -> &mut StdoutLock<'lock> {
|
fn stdout(&mut self) -> &mut StdoutLock<'lock> {
|
||||||
self.stdout
|
self.stdout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CountedWrite<'a> for StdoutLock<'a> {
|
impl<'a> CountedWrite<'a> for StdoutLock<'a> {
|
||||||
#[inline]
|
|
||||||
fn write_ascii(&mut self, ascii: &[u8]) -> io::Result<()> {
|
fn write_ascii(&mut self, ascii: &[u8]) -> io::Result<()> {
|
||||||
self.write_all(ascii)
|
self.write_all(ascii)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write_str(&mut self, unicode: &str) -> io::Result<()> {
|
fn write_str(&mut self, unicode: &str) -> io::Result<()> {
|
||||||
self.write_all(unicode.as_bytes())
|
self.write_all(unicode.as_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn stdout(&mut self) -> &mut StdoutLock<'a> {
|
fn stdout(&mut self) -> &mut StdoutLock<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,6 @@ static EXERCISE_RUNNING: AtomicBool = AtomicBool::new(false);
|
|||||||
pub struct InputPauseGuard(());
|
pub struct InputPauseGuard(());
|
||||||
|
|
||||||
impl InputPauseGuard {
|
impl InputPauseGuard {
|
||||||
#[inline]
|
|
||||||
pub fn scoped_pause() -> Self {
|
pub fn scoped_pause() -> Self {
|
||||||
EXERCISE_RUNNING.store(true, Relaxed);
|
EXERCISE_RUNNING.store(true, Relaxed);
|
||||||
Self(())
|
Self(())
|
||||||
@ -35,7 +34,6 @@ impl InputPauseGuard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for InputPauseGuard {
|
impl Drop for InputPauseGuard {
|
||||||
#[inline]
|
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
EXERCISE_RUNNING.store(false, Relaxed);
|
EXERCISE_RUNNING.store(false, Relaxed);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,19 +19,16 @@ struct Cmd<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Cmd<'a> {
|
impl<'a> Cmd<'a> {
|
||||||
#[inline]
|
|
||||||
fn current_dir(&mut self, current_dir: &'a str) -> &mut Self {
|
fn current_dir(&mut self, current_dir: &'a str) -> &mut Self {
|
||||||
self.current_dir = Some(current_dir);
|
self.current_dir = Some(current_dir);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn args(&mut self, args: &'a [&'a str]) -> &mut Self {
|
fn args(&mut self, args: &'a [&'a str]) -> &mut Self {
|
||||||
self.args = args;
|
self.args = args;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn output(&mut self, output: Output<'a>) -> &mut Self {
|
fn output(&mut self, output: Output<'a>) -> &mut Self {
|
||||||
self.output = Some(output);
|
self.output = Some(output);
|
||||||
self
|
self
|
||||||
@ -70,13 +67,11 @@ impl<'a> Cmd<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn success(&self) {
|
fn success(&self) {
|
||||||
self.assert(true);
|
self.assert(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn fail(&self) {
|
fn fail(&self) {
|
||||||
self.assert(false);
|
self.assert(false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user