mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-22 05:52:23 -05:00
Fix lifetimes
This commit is contained in:
parent
b0a4750624
commit
2db86833a9
1 changed files with 12 additions and 8 deletions
20
src/list.rs
20
src/list.rs
|
@ -16,27 +16,31 @@ use std::io;
|
||||||
|
|
||||||
use crate::{exercise::Exercise, state::State};
|
use crate::{exercise::Exercise, state::State};
|
||||||
|
|
||||||
fn rows<'s, 'e>(state: &'s State, exercises: &'e [Exercise]) -> impl Iterator<Item = Row<'e>> + 's
|
fn rows<'s, 'e, 'i>(
|
||||||
|
state: &'s State,
|
||||||
|
exercises: &'e [Exercise],
|
||||||
|
) -> impl Iterator<Item = Row<'e>> + 'i
|
||||||
where
|
where
|
||||||
'e: 's,
|
's: 'i,
|
||||||
|
'e: 'i,
|
||||||
{
|
{
|
||||||
exercises
|
exercises
|
||||||
.iter()
|
.iter()
|
||||||
.zip(state.progress())
|
.zip(state.progress())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(ind, (exercise, done))| {
|
.map(|(ind, (exercise, done))| {
|
||||||
let exercise_state = if *done {
|
|
||||||
"DONE".green()
|
|
||||||
} else {
|
|
||||||
"PENDING".yellow()
|
|
||||||
};
|
|
||||||
|
|
||||||
let next = if ind == state.next_exercise_ind() {
|
let next = if ind == state.next_exercise_ind() {
|
||||||
">>>>".bold().red()
|
">>>>".bold().red()
|
||||||
} else {
|
} else {
|
||||||
Span::default()
|
Span::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let exercise_state = if *done {
|
||||||
|
"DONE".green()
|
||||||
|
} else {
|
||||||
|
"PENDING".yellow()
|
||||||
|
};
|
||||||
|
|
||||||
Row::new([
|
Row::new([
|
||||||
next,
|
next,
|
||||||
exercise_state,
|
exercise_state,
|
||||||
|
|
Loading…
Reference in a new issue