From b521ce6ed06f8a3f6c5fe1f9a79f3b97d4151349 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 6 Oct 2023 15:33:07 +0200 Subject: cargo fmt --- src/main.rs | 59 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8668a82..9e08418 100644 --- a/src/main.rs +++ b/src/main.rs @@ -989,7 +989,8 @@ fn add_examples(all_batches: &mut [Batch], examples: &[Example]) { for (i, batch) in all_batches.iter_mut().enumerate() { chars = chars.union(&batch.chars); - let candidates = examples.iter() + let candidates = examples + .iter() .filter(|x| x.chars.inter_len(&batch.chars) > 0) .filter(|x| x.chars.diff(&chars).len() == 0) .filter(|x| batch.examples.iter().all(|y| y.ja != x.ja)); @@ -997,12 +998,14 @@ fn add_examples(all_batches: &mut [Batch], examples: &[Example]) { for c in candidates { cand_by_chars.insert(c.chars.to_string(), c.clone()); } - let mut candidates = cand_by_chars.into_iter().map(|(_, ex)| ex).collect::>(); + let mut candidates = cand_by_chars + .into_iter() + .map(|(_, ex)| ex) + .collect::>(); candidates.shuffle(&mut thread_rng()); candidates.truncate(20); batch.extra_examples = candidates; - println!("---- BATCH #{:03} ----", i); for ex in batch.extra_examples.iter() { println!("{} - {}", ex.ja, ex.en); @@ -1125,20 +1128,33 @@ fn format_batch_aux<'a>( writeln!(f, "
")?; format_vocab( &mut f, - &batch.extra_vocab.iter().filter(|v| batch.level.contains(&v.level)).collect::>(), - "Extra vocabulary (this level)")?; + &batch + .extra_vocab + .iter() + .filter(|v| batch.level.contains(&v.level)) + .collect::>(), + "Extra vocabulary (this level)", + )?; format_vocab( &mut f, - &batch.extra_vocab.iter().filter(|v| !batch.level.contains(&v.level)).collect::>(), - "Extra vocabulary (previous levels)")?; + &batch + .extra_vocab + .iter() + .filter(|v| !batch.level.contains(&v.level)) + .collect::>(), + "Extra vocabulary (previous levels)", + )?; - writeln!(f, r#"
Extra examples (reading practice)"#)?; + writeln!( + f, + r#"
Extra examples (reading practice)
"# + )?; for ex in batch.extra_examples.iter() { - writeln!( - f, - r#""#, - ex.ja, ex.en - )?; + writeln!( + f, + r#""#, + ex.ja, ex.en + )?; } writeln!(f, r#"
  {}  
{}
  {}  
{}
"#)?; @@ -1152,7 +1168,11 @@ fn format_batch_aux<'a>( fn format_vocab(f: &mut impl Write, vocab: &[&JlptVocab], t: &str) -> Result<()> { if !vocab.is_empty() { - writeln!(f, r#"
{}"#, t)?; + writeln!( + f, + r#"
{}
"#, + t + )?; for v in vocab { writeln!( f, @@ -1287,9 +1307,16 @@ fn format_about() -> Result<()> { )?; writeln!(f, r#"
"#)?; - writeln!(f, r#"

Back to lessons


"#)?; + writeln!( + f, + r#"

Back to lessons


"# + )?; - writeln!(f, "{}", markdown::to_html(&fs::read_to_string("README.md")?))?; + writeln!( + f, + "{}", + markdown::to_html(&fs::read_to_string("README.md")?) + )?; writeln!(f, r#"
"#)?; -- cgit v1.2.3