mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-05-15 09:48:45 +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))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn current_exercise_ind(&self) -> usize {
|
||||
self.current_exercise_ind
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn exercises(&self) -> &[Exercise] {
|
||||
&self.exercises
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_done(&self) -> u32 {
|
||||
self.n_done
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_pending(&self) -> u32 {
|
||||
self.exercises.len() as u32 - self.n_done
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn current_exercise(&self) -> &Exercise {
|
||||
&self.exercises[self.current_exercise_ind]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn cmd_runner(&self) -> &CmdRunner {
|
||||
&self.cmd_runner
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn emit_file_links(&self) -> bool {
|
||||
self.emit_file_links
|
||||
}
|
||||
|
||||
@ -126,7 +126,6 @@ pub struct CargoSubcommand<'out> {
|
||||
}
|
||||
|
||||
impl CargoSubcommand<'_> {
|
||||
#[inline]
|
||||
pub fn args<'arg, I>(&mut self, args: I) -> &mut Self
|
||||
where
|
||||
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.
|
||||
#[inline]
|
||||
pub fn run(self, description: &str) -> Result<bool> {
|
||||
run_cmd(self.cmd, description, self.output)
|
||||
}
|
||||
|
||||
@ -158,7 +158,6 @@ pub trait RunnableExercise {
|
||||
|
||||
/// Compile, check and run the exercise.
|
||||
/// 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> {
|
||||
self.run::<false>(self.name(), output, cmd_runner)
|
||||
}
|
||||
@ -201,22 +200,18 @@ pub trait RunnableExercise {
|
||||
}
|
||||
|
||||
impl RunnableExercise for Exercise {
|
||||
#[inline]
|
||||
fn name(&self) -> &str {
|
||||
self.name
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn dir(&self) -> Option<&str> {
|
||||
self.dir
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn strict_clippy(&self) -> bool {
|
||||
self.strict_clippy
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn test(&self) -> bool {
|
||||
self.test
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ pub struct ExerciseInfo {
|
||||
#[serde(default)]
|
||||
pub skip_check_unsolved: bool,
|
||||
}
|
||||
#[inline]
|
||||
const fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
@ -55,22 +54,18 @@ impl ExerciseInfo {
|
||||
}
|
||||
|
||||
impl RunnableExercise for ExerciseInfo {
|
||||
#[inline]
|
||||
fn name(&self) -> &str {
|
||||
self.name
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn dir(&self) -> Option<&str> {
|
||||
self.dir
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn strict_clippy(&self) -> bool {
|
||||
self.strict_clippy
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn test(&self) -> bool {
|
||||
self.test
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ impl ScrollState {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn offset(&self) -> usize {
|
||||
self.offset
|
||||
}
|
||||
@ -41,7 +40,6 @@ impl ScrollState {
|
||||
.min(global_max_offset);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn selected(&self) -> Option<usize> {
|
||||
self.selected
|
||||
}
|
||||
@ -86,12 +84,10 @@ impl ScrollState {
|
||||
self.set_selected(self.selected.map_or(0, |selected| selected.min(n_rows - 1)));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn update_scroll_padding(&mut self) {
|
||||
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 {
|
||||
self.max_n_rows_to_display
|
||||
}
|
||||
|
||||
@ -303,7 +303,6 @@ impl<'a> ListState<'a> {
|
||||
self.scroll_state.set_n_rows(n_rows);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn filter(&self) -> Filter {
|
||||
self.filter
|
||||
}
|
||||
@ -313,22 +312,18 @@ impl<'a> ListState<'a> {
|
||||
self.update_rows();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn select_next(&mut self) {
|
||||
self.scroll_state.select_next();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn select_previous(&mut self) {
|
||||
self.scroll_state.select_previous();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn select_first(&mut self) {
|
||||
self.scroll_state.select_first();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn select_last(&mut self) {
|
||||
self.scroll_state.select_last();
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ pub struct MaxLenWriter<'a, 'lock> {
|
||||
}
|
||||
|
||||
impl<'a, 'lock> MaxLenWriter<'a, 'lock> {
|
||||
#[inline]
|
||||
pub fn new(stdout: &'a mut StdoutLock<'lock>, max_len: usize) -> Self {
|
||||
Self {
|
||||
stdout,
|
||||
@ -28,7 +27,6 @@ impl<'a, 'lock> MaxLenWriter<'a, 'lock> {
|
||||
}
|
||||
|
||||
// Additional is for emojis that take more space.
|
||||
#[inline]
|
||||
pub fn add_to_len(&mut self, additional: usize) {
|
||||
self.len += additional;
|
||||
}
|
||||
@ -64,24 +62,20 @@ impl<'lock> CountedWrite<'lock> for MaxLenWriter<'_, 'lock> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn stdout(&mut self) -> &mut StdoutLock<'lock> {
|
||||
self.stdout
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CountedWrite<'a> for StdoutLock<'a> {
|
||||
#[inline]
|
||||
fn write_ascii(&mut self, ascii: &[u8]) -> io::Result<()> {
|
||||
self.write_all(ascii)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_str(&mut self, unicode: &str) -> io::Result<()> {
|
||||
self.write_all(unicode.as_bytes())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn stdout(&mut self) -> &mut StdoutLock<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
@ -27,7 +27,6 @@ static EXERCISE_RUNNING: AtomicBool = AtomicBool::new(false);
|
||||
pub struct InputPauseGuard(());
|
||||
|
||||
impl InputPauseGuard {
|
||||
#[inline]
|
||||
pub fn scoped_pause() -> Self {
|
||||
EXERCISE_RUNNING.store(true, Relaxed);
|
||||
Self(())
|
||||
@ -35,7 +34,6 @@ impl InputPauseGuard {
|
||||
}
|
||||
|
||||
impl Drop for InputPauseGuard {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
EXERCISE_RUNNING.store(false, Relaxed);
|
||||
}
|
||||
|
||||
@ -19,19 +19,16 @@ struct Cmd<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Cmd<'a> {
|
||||
#[inline]
|
||||
fn current_dir(&mut self, current_dir: &'a str) -> &mut Self {
|
||||
self.current_dir = Some(current_dir);
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn args(&mut self, args: &'a [&'a str]) -> &mut Self {
|
||||
self.args = args;
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn output(&mut self, output: Output<'a>) -> &mut Self {
|
||||
self.output = Some(output);
|
||||
self
|
||||
@ -70,13 +67,11 @@ impl<'a> Cmd<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn success(&self) {
|
||||
self.assert(true);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn fail(&self) {
|
||||
self.assert(false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user